cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sacheu
New Member

How can I create a Dictionary data structure in MS Flow?

In my flow, I need to make a http call and it returns an array of JSON objects as response.

And I need to loop thru the response and count how many entries which the same name.

 

For example, 

 

{
  "Team": [
    {
      "name": "Tom",
	"task": 1345
    },
    {
      "name": "Robert",
	"task": 1346
    },
    {
      "name": "Robert",
	"task": 1246
    },
 	{
      "name": "Mary",
	"task": 1366
    }
  ]
}

 

And in my flow, i need to count, Mary , Tom has 1 task, and Robert has 2 tasks.

And the name in the json reponse is unknown before hand.

 

I am thinking to create a dictionary and loop thru each element in the json response. 

But i don't see a way for me to create a dictionary in ms flow.

 

Does anyone has any other idea?

 

Thank you.

 

1 ACCEPTED SOLUTION

Accepted Solutions
manuelstgomes
Community Champion
Community Champion

Hi @sacheu 

 

Nope no dictionary. You need to do a "For Each" in each element in the Team and have 2 arrays. One for the "keys" (the people) and another for the "values" (your count of tasks).

 

Then you need to find the index in the keys array and use that index in the values array.

 

I know this is not a dictionary, but this is the only way I can see that you can achieve what you need.

 

Hope this helps

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

View solution in original post

3 REPLIES 3
manuelstgomes
Community Champion
Community Champion

Hi @sacheu 

 

Nope no dictionary. You need to do a "For Each" in each element in the Team and have 2 arrays. One for the "keys" (the people) and another for the "values" (your count of tasks).

 

Then you need to find the index in the keys array and use that index in the values array.

 

I know this is not a dictionary, but this is the only way I can see that you can achieve what you need.

 

Hope this helps

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

Thanks for your answer.

 

Regarding `You need to do a "For Each" in each element in the Team and have 2 arrays. One for the "keys" (the people) and another for the "values" (your count of tasks).`,

 

Assume i have the foreach loop to find the index of the key array, I can't find a way in which in can increment an element in my values array.

MS flow only let me pick the whole array variable, not an elment of that array variable.

 

 

chris_l
Regular Visitor

I need to do exactly the same thing. I have a bookings file by location - I need to count how many bookings I have on each location, ideally by date (although I can make that part of the key). In other software I would check the dictionary for the key: if it doesn't exist, add it, if it does, increment it.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,819)