
Hi,
You’re on the right track. To add TotalAudits, FailedAudits, and PassRate from your Select 3 array into the output of Select‑shape the audit scan exceptions data, use a lookup inside the loop and then map the fields. Below is a step‑by‑step approach that matches your screenshot.
For each item coming out of Select‑shape 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.
1) Apply to each
Loop over the output of Select‑shape 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 Select‑shape 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 cross‑references), 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.