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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Adding values from one...
Power Automate
Answered

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

(0) ShareShare
ReportReport
Posted on by 881 Super User 2026 Season 1
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!
 
 
 
 
 
Categories:
I have the same question (0)
  • Suggested answer
    sannavajjala87 Profile Picture
    224 Super User 2026 Season 1 on at

    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.

  • Cgangweg01 Profile Picture
    881 Super User 2026 Season 1 on at
     
    Thanks for the reply. I'm not quite following your instructions. There appears to be some extra words pasted into the expressions from wherever they were copied. Unfortunately, I'm still relying on pictures to help me as well!
     
    I think what is being suggested is a Filter within the Apply to each loop that I already have in order to iterate over ShopperID but I'm not sure how to set that up from the instructions given.
     
    Note that the SQL statements are for different query/tables so that is why these are separate.
     
    Is there anything else I can provide to help explain the need or show my flow as is?
     
    Copying in @Michael E. Gernaey  for some possible assist.
     
    Appreciate it!
  • Verified answer
    Cgangweg01 Profile Picture
    881 Super User 2026 Season 1 on at
    Hello -
     
    Figured this out. If anyone is interested this solution is roughly close to the suggested answer above but with actions pictured below. If anyone wants more of the expressions used, let me know.
     
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 922

#2
Valantis Profile Picture

Valantis 837

#3
Haque Profile Picture

Haque 534

Last 30 days Overall leaderboard