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

Community site session details

Session Id :
Power Automate - Using Flows
Unanswered

Adding values from one array to another array in an Apply to Each

(0) ShareShare
ReportReport
Posted on by 589 Super User 2025 Season 2
Hello -
 
Feel like I've done this before, but I can't figure it out at the moment.
 
Trying to add the results of the 'Select 3' action to the output of the 'Select-shape the audit scan exceptions data" action as filtered. The fields to be added are TotalAudits, FailedAudits, PassRate which match in each array. The apply to each is iterating on ShopperID also matching in each array.
 
Am I headed down the right path using the Apply to each? TIA!
 
 
 
 
 
I have the same question (0)
  • Suggested answer
    sannavajjala87 Profile Picture
    107 on at
    Adding values from one array to another array in an Apply to Each

    Hi,

    You’re on the right track. To add TotalAudits, FailedAudits, and PassRate from your Select 3 array into the output of Selectshape the audit scan exceptions data, use a lookup inside the loop and then map the fields. Below is a stepbystep approach that matches your screenshot.

    For each item coming out of Selectshape the audit scan exceptions data (left screenshot), find the matching record in Select 3 (right screenshot) by a shared key (ShopperID or ItemNumber, whichever truly matches both arrays), and populate:

    TotalAudits

    FailedAudits

    PassRate

     

    From your middle screenshot you’re filtering by ItemNumber, but both arrays also have ShopperID. Pick the key that reliably exists in both arrays and is unique per row. I’ll show both options—use only one.

     

    Approach: Filter → First → Map fields

     

    1) Apply to each

    Loop over the output of Selectshape the audit scan exceptions data:

     

    Apply to each → Input:

    outputs('Select-shape_the_audit_scan_exceptions_data')

     

    (This is the array you want to enrich.)

     

    2) Filter array (lookup in Select 3)

    Inside the loop, filter Select 3 to find the matching record.

    Option A — Match by ItemNumber:

     

    Filter array → From:

    outputs('Select_3')

     

     

    Condition (in advanced mode):

    Plain Textitem()?['ItemNumber'] is equal to items('Apply_to_each')?['ItemNumber']Show more lines

     

     

    Option B — Match by ShopperID:

     

    Filter array → From:

    outputs('Select_3')

     

    Condition:

    Plain Textitem()?['ShopperID'] is equal to items('Apply_to_each')?['ShopperID']Show more lines

    Use whichever key truly aligns between both arrays. If both exist, prefer the one with guaranteed uniqueness.

     

    3) Compose the match (safe first)

    Add a Compose action to safely pick the first matched row (or null if not found):

    Plain Textif( equals(length(body('Filter_array')), 0), null, first(body('Filter_array')))Show more lines

    Name this Compose_Match.

     

    4) Map the three fields in your Select action

    Go back to Selectshape the audit scan exceptions data and fill in the three empty fields using expressions that reference the match. For each field, use coalesce() so your flow won’t fail if there’s no match.

     

    TotalAudits:

    Plain Textcoalesce(outputs('Compose_Match')?['TotalAudits'], 0)Show more lines

     

    FailedAudits:

    Plain Textcoalesce(outputs('Compose_Match')?['FailedAudits'], 0)Show more lines

     

    PassRate:

    Plain Textcoalesce(outputs('Compose_Match')?['PassRate'], 0)Show more lines

    If you prefer to keep your Select “pure” (no crossreferences), another pattern is to Compose a merged object inside the loop and Append to array variable. But given your design, populating these three fields directly in the Select using the matched record works fine.

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

Coming soon: forum hierarchy changes

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

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 481 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 472 Super User 2025 Season 2

#3
Expiscornovus Profile Picture

Expiscornovus 245 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Restore a deleted flow