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 / Array not working prop...
Power Automate
Suggested Answer

Array not working properly

(0) ShareShare
ReportReport
Posted on by 559
I have the below power automate but noticed that array is not working properly.
 
The output i got is as per screenshot below.
 
 
However the expected output should be something like below. May i know where i am going wrong? I have included the Power Automate screenshot below. 
 
 
 
 
 
I have the same question (0)
  • Suggested answer
    WillPage Profile Picture
    2,319 Super User 2026 Season 1 on at
    There's quite a lot to cover here, but I'll try and be brief!

    The output array (value) from your Get emails action should go into a Filter array action. The filter condition being subject contains AIS
     
    Now the output of that should go into a Select. Press the button to convert from key-value input into JSON mode, and in the box, add the expression substring(item()?['Subject'], indexOf(item()?['Subject'], 'AIS'), 7)
     
    This will result in a single column array of your AIS numbers, many will be duplicated.

    Now, add a compose and in there, go union(body('Select'),body('Select')). This dedupes the array into a set of unique AISRefNum values.
     
    Next, add an Apply to each and put this de-duped array into its input, so you get one iteration per distinct AIS number
     
    Inside the Apply to each, add a Filter array (it'll be called Filter array 2 for the sake of this example). Filter the non-deduped version of the array (the original Select action output) for item() equals items('Apply_to_each'). So you're filtering the non-deduped array for the value of the current iteration of the loop. The result will have one or more items of identical AIS numbers.

    You can count those items with the length() function on the result. Add a Compose to do this (let's call it Compose 2) and set it like {"AISRefNo": "@{items("Apply_to_each")}", "Number of Emails": @{length(body('Filter_array_2'))}}  where @{} denotes an expression and everything else is just typed directly into the Compose input.

    What you're doing here is making a JSON object with two properties, one called AISRefNo with the value of the current iteration of the loop, and another called Number of Emails with the count of matching ref numbers from the non-deduped array from earlier.

    Finally outside the Apply to each loop, do a Compose and add the expression outputs('Compose_2'). This will result in an array you can then run through the Create HTML Table function or whatever you want to do with it.

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!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 293

#2
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 223 Most Valuable Professional

Last 30 days Overall leaderboard