web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Apply to Each and Arrays
Power Automate
Unanswered

Apply to Each and Arrays

(0) ShareShare
ReportReport
Posted on by 87

I have an Array Variable that has an output of this:

[
  "",
  "",
  "Approaching or Over Due Date Notification",
  "[/global/ctp/study/_layouts/15/WrkStat.aspx?WorkflowInstanceID={E379A985-70EF-46A2-B4FC-3AB4E6ECF382}]",
  "4/12/2024 10:13 PM",
  "Error Occurred",
  "[/global/ctp/study/_layouts/15/WrkStat.aspx?WorkflowInstanceID={E379A985-70EF-46A2-B4FC-3AB4E6ECF382}]",
  "",
  "Approaching or Over Due Date Notification",
  "[/global/ctp/study/_layouts/15/WrkStat.aspx?WorkflowInstanceID={5AF0E797-38EF-4696-97E2-7D9E2C14CA27}]",
  "4/12/2024 5:11 AM",
  "Failed on Start (retrying)",
  "[/global/ctp/study/_layouts/15/WrkStat.aspx?WorkflowInstanceID={5AF0E797-38EF-4696-97E2-7D9E2C14CA27}]",
  "",
  "Approaching or Over Due Date Notification",
  "[/global/ctp/study/_layouts/15/WrkStat.aspx?WorkflowInstanceID={55955119-4339-4F9C-8093-EAF2EB3DCCE3}]",
  "4/11/2024 10:38 PM",
  "Failed on Start (retrying)",
  "[/global/ctp/study/_layouts/15/WrkStat.aspx?WorkflowInstanceID={55955119-4339-4F9C-8093-EAF2EB3DCCE3}]",
  "",
  "Approaching or Over Due Date Notification",
  "[/global/ctp/study/_layouts/15/WrkStat.aspx?WorkflowInstanceID={71F27A42-617C-495E-903E-7627C35F587E}]",
  "4/4/2024 2:48 PM",
  "Failed on Start (retrying)",
  "[/global/ctp/study/_layouts/15/WrkStat.aspx?WorkflowInstanceID={71F27A42-617C-495E-903E-7627C35F587E}]",
  "",
  "Approaching or Over Due Date Notification",
  "[/global/ctp/study/_layouts/15/WrkStat.aspx?WorkflowInstanceID={E2D08147-6631-4C8E-BE34-757F87922141}]",
  "3/30/2024 12:01 PM",
  "Failed on Start (retrying)",
  "[/global/ctp/study/_layouts/15/WrkStat.aspx?WorkflowInstanceID={E2D08147-6631-4C8E-BE34-757F87922141}]",
  "",
  "Study Distribution List Review",
  "[/global/ctp/study/_layouts/15/WrkStat.aspx?WorkflowInstanceID={740F8E61-AECA-42A6-9C4D-86C7D75B3F89}]",
  "3/30/2024 11:25 AM",
  "Error Occurred",
  "[/global/ctp/study/_layouts/15/WrkStat.aspx?WorkflowInstanceID={740F8E61-AECA-42A6-9C4D-86C7D75B3F89}]",
  "",
 
The next step is an apply to each with a compose (Take) action.  The expression for the Take action is take(skip(variables('WorkflowArray'), 2), 5)  The issue I am coming across is the apply to each run 266 times but for each instance of the loop it is the same output which is the first 5 of the start of my array:
[
  "Approaching or Over Due Date Notification",
  "[/global/ctp/study/_layouts/15/WrkStat.aspx?WorkflowInstanceID={E379A985-70EF-46A2-B4FC-3AB4E6ECF382}]",
  "4/12/2024 10:13 PM",
  "Error Occurred",
  "[/global/ctp/study/_layouts/15/WrkStat.aspx?WorkflowInstanceID={E379A985-70EF-46A2-B4FC-3AB4E6ECF382}]"
]
 
How can I have it loop through the rest of the array?  I am pretty sure I have to fix my take expression but not sure how.

skarthanal25_1-1714156917510.png

skarthanal25_2-1714157366796.png

 

Categories:
I have the same question (0)
  • Verified answer
    ManishSolanki Profile Picture
    15,091 Super User 2025 Season 2 on at

    Hi @skarthanal25 

     

    Here are the actions that help you in solving this problem.

     

    Firstly, use "Filter array" to filter nonempty elements in the array variable. Pass the value of variable as the input of filter array action:

    ManishSolanki_0-1714194708278.png

    Click 'Edit in advanced mode' button on the bottom of this action and enter the below query in the textbox:

    @not(equals(item(), ''))

     

    Next, add "Apply to each" action and using expression with chunk() function, we will make a group of 5 elements by creating a nested array:

    ManishSolanki_2-1714194911873.png

    chunk(body('Filter_array'),5)

    When we iterate, we get an array with 5 elements in each iteration. You can use index to retrieve the values of each within the group. I have used compose action to show how we can get the first value from the nested array (group). Add "Compose" action in the 'Apply to each' block and enter the below expression:

    ManishSolanki_3-1714195099448.png

    items('Apply_to_each')[0]

    Similarly, use index 1 to 4 to get the values of other elements in the nested array (group).

     

     

    Output:

    ManishSolanki_4-1714195227199.pngManishSolanki_5-1714195248549.png

     

     

     

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

  • skarthanal25 Profile Picture
    87 on at

    @ManishSolanki Thank you again, this solution worked out perfectly!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard