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 / Hash Table / Dictionar...
Power Automate
Unanswered

Hash Table / Dictionary in Power Automate Online Flows

(0) ShareShare
ReportReport
Posted on by 4

While working on parsing some JSON objects with non-uniform names and quantities that needed to be tallied, I found myself in need of a hash table / dictionary. After a bit of research I settled on the setProperty approach:

 

Initialization
Variable ObjItems = {}
Variable ArrayObjItemsKeys = []

 

1. Compose Deployed Equipment Property Key
Action: Compose

Input:

replace(toLower(concat(body('Parse_JSON_from_Deployed_Equipment')?['Item'],';',coalesce(body('Parse_JSON_from_Deployed_Equipment')?['ItemState'],''))), '.', '_')

Concatenate two fields together to make the property key, case-insensitive. The replace function ensures the invalid period character is not used.

 

2. Compose Deployed Equipment Updated Nested Object
Action: Compose
Input:

{
"ItemName": "@{body('Parse_JSON_from_Deployed_Equipment')?['Item']}",
"ItemState": "@{body('Parse_JSON_from_Deployed_Equipment')?['ItemState']}",
"EquipmentType": "@{body('Parse_JSON_from_Deployed_Equipment')?['EquipmentType']}",
"Quantity": @{add(coalesce(variables('ObjItems')?[outputs('Compose_Deployed_Equipment_Property_Key')]?['Quantity'], 0),body('Parse_JSON_from_Deployed_Equipment')?['Quantity'])},
"CustomerCharge": @{coalesce(body('Parse_JSON_from_Deployed_Equipment')?['Customer_Charge'], 0)},
"Cost": @{coalesce(body('Parse_JSON_from_Deployed_Equipment')?['Cost'], 0)}
}

Include the values from the parsed JSON data, adding the quantity to the existing object if it already exists. The result is stored in the Compose action's output as a JSON object.

 

3. Compose Deployed Equipment Updated ObjItems
Action: Compose
Input:

setProperty(variables('ObjItems'), outputs('Compose_Deployed_Equipment_Property_Key'), outputs('Compose_Deployed_Equipment_Updated_Nested_Object'))

Call setProperty to generate a new updated JSON object.

 

4. Set variable ObjItems for Deployed Equipment
Action: Set variable
Input:

outputs('Compose_Deployed_Equipment_Updated_ObjItems')

Update the ObjItems variable with the updated nested object from the setProperty call.

 

5a. If New ObjItems Key from Deployed Equipment
Action: Condition
Input:

contains(variables('ArrayObjCountsKeys'), outputs('Compose_Deployed_Equipment_Property_Key')) is equal to false

 

5b. Append new key to ArrayObjItemsKeys for Deployed Equipment
Action: Append Array Variable
Input:

outputs('Compose_Deployed_Equipment_Property_Key')

Appends the new key to the array of keys if it doesn't already exist. This allows looping over the keys.

 

Most of these steps could technically be combined into one call, but it can be nice for debugging to have them separated.

 

The downside to this approach is that any loops setting the object variable cannot have parallelism. In the loop settings, Concurrency Control must be enabled with the Degree of Parallelism set to 1. This can significantly increase the flow duration depending on the number of objects that need to be parsed.

 

Hopefully one day we'll get a more proper way of dealing with dictionaries in Power Automate online, but this way works for now.

 

Any suggestions for a more efficient way of handling dictionaries in PA Online would be welcome.

 

mcarras_0-1712776383173.png

 

mcarras_1-1712776428703.png

 

Categories:

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 321 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 244

#3
Henil Profile Picture

Henil 102

Last 30 days Overall leaderboard