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 / Iterate through a Json...
Power Automate
Unanswered

Iterate through a Json array?

(2) ShareShare
ReportReport
Posted on by 87

Hello there,

 

I have a Json structure like that

 


[
 {
  "ColumnID": "1",
  "Column1": "Main directory1",
  "Column2": "Sub directory1",
  "Column3": "Documents1",

 },

 {
  "ColumnID": "2",
  "Column1": "Main directory2",
  "Column2": "Sub directory2",
  "Column3": "Documents2",

 },

 {
  "ColumnID": "3",
  "Column1": "Main directory3",
  "Column2": "Sub directory3",
  "Column3": "Documents3",

 },
]

 


I would like to iterate through it so that at each iteration I read the following values:
First iteration: Main directory1
Second iteration: Main directory2
Third iteration: Main directory3


What I did until now? I declared a variable iteratorRow that starts from 1, I filter the array to get the #iteratorRow location, I compose it to get the single array (and not the object), I compose it again to get the single value.

This flow is working if I am not using "Do until" and I want to get a single value of the Json array.

 

image.png

 

 

The big problem is the "Step1 Filter array" action. It can not get a variable on the right, it must be a string. This is driving me insane.
-I try to edit in advance mode like this: "@equals(item()?['ColumnID'], variables('iteratorRow'))" but nothing.
-I try to build a string with the value of iteratorRow and then concat a series of variable to have something like this @equals(item()?['ColumnID'], 'theActualIteratorRow'  but I cant pass a variable in advance edit.

Do you have a solution or workaround to this problem? 

Categories:
I have the same question (0)
  • jinivthakkar Profile Picture
    4,187 on at

    @dignus93reply I found a similar thread here :

     

    https://powerusers.microsoft.com/t5/Building-Flows/Convert-JSON-array-to-string-array/m-p/395040

     

    https://powerusers.microsoft.com/t5/General-Power-Automate/For-each-sum-JSON-array/m-p/557499

     

     

    --------------------------------------------------------------------------------

    If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

  • mahoneypat Profile Picture
    1,720 on at

    Why not just use an Apply To Each on your array instead of Do Until?

    Pat

  • Verified answer
    dignus93reply Profile Picture
    87 on at

    Thanks for all the good advice folks.

     

    I solved like this: I declare the json array in a string variable. I parse it in Json. In the parse JSON action I click "generate from sample" and I paste the json array. It will generate automatically a schema. Then I loop through it with an Apply to each. In the "select an output from previous steps" of the apply to each I chose the Body of the parse JSON. Inside I read the Column1.

     

    Finally I can get my desired output
    "Main directory1" at iteration1;

    "Main directory2" at iteration2;

    "Main directory3" at iteration3

    s1.png

     
  • HEATFreight Profile Picture
    1,024 on at

    holy smokes @dignus93reply you just saved me from the counter-variable apocalypse!

    I did exactly what you said and now I am able to fully parameterize files using Parse JSON and no counters!

    Thanks brother, I owe you one👆

  • HEATFreight Profile Picture
    1,024 on at

    Yo @dignus93reply, just to update you on my progress... I am now nesting Parse JSON actions within each other to parametrically grab specific attributes and populate them into arrays for later processing, all thanks to your solution!

    The more I think about it, the more I think nesting them may be unnecessary, because by it's very nature the Parse JSON action should make all of the properties accessible if the right schema is used, but it's not always easy to code working logic with such a massive set of dynamic content, so a nested pair of Parse JSON actions has proven extremely powerful in my use case, and it would not be possible without your little trick!

  • ChrisMendoza Profile Picture
    425 on at

    @dignus93reply- I know I'm late to the party here however, I had a similar need and I solved as:

    items('Apply_to_each')?['Column1']

     

    image.png

    image.png

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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard