Logic Apps Data Mapper makes it easy to define visual, code-free transformations across structured JSON data. One pattern that's both powerful and clean: using built-in collection functions to compute summary values from arrays.
This post walks through an end-to-end example: calculating a total from a list of items using just two functions โ `Multiply` and `Sum`.
๐งพ Scenario: Line Item Totals + Order Summary
Youโre working with a list of order items. For each item, you want to:
- Compute Total = Quantity ร Price
- Then, compute the overall OrderTotal by summing all the individual totals
๐ฅ Input
{ "orders" : [ { "Quantity" : 10, "Price" : 100 }, { "Quantity" : 20, "Price" : 200 }, { "Quantity" : 30, "Price" : 300 } ] }
๐ค Output
{ "orders" : [ { "Quantity" : 10, "Price" : 100, "Total" : 1000 }, { "Quantity" : 20, "Price" : 200, "Total" : 4000 }, { "Quantity" : 30, "Price" : 300, "Total" : 9000 } ], "Summary": { "OrderTotal": 14000 } }
๐ง Step-by-step walkthrough
๐๏ธ 1. Load schemas in Data Mapper
Start in the Azure Data Mapper interface and load:
- Source schema: contains the orders array with Quantity and Price
- Target schema: includes a repeating orders node and a Summary โ OrderTotal field
๐ธ Docked schemas in the mapper
๐ 2. Recognize the repeating node
The orders array shows a ๐ icon on <ArrayItem>, marking it as a repeating node.
๐ธ Repeating node detection
๐ก When you connect child fields like Quantity or Price, the mapper auto-applies a loop for you. No manual loop configuration needed.
โ 3. Multiply Quantity ร Price (per item)
Drag in a Multiply function and connect:
- Input 1: Quantity
- Input 2: Price
Now connect the output of Multiply directly to the Total node under Orders node in the destination.
This runs once per order item and produces individual totals:
[1000, 4000, 9000]
๐ธ Multiply setup
โ 4. Aggregate All Totals Using Sum
Use the same Multiply function output and pass it into a Sum function. This will combine all the individual totals into one value. Drag and connect:
- Input 1: multiply(Quantity, Price)
- Input 2: <ArrayItem>
Connect the output of Sum to the destination node Summary โ OrderTotal
1000 + 4000 + 9000 = 14000
๐ธ Sum function
โ 5. Test the Output
Run a test with your sample input by clicking on the Open test panel. Copy/paste the sample data and hit Test.
The result should look like this:
{
"orders": [
{
"Quantity": 10,
"Price": 100,
"Total": 1000
},
{
"Quantity": 20,
"Price": 200,
"Total": 4000
},
{
"Quantity": 30,
"Price": 300,
"Total": 9000
}
],
"Summary": {
"OrderTotal": 14000
}
}
๐ง Why this pattern works
- ๐ Repeating to repeating: Youโre calculating Total per order
- ๐ Repeating to non-repeating: Youโre aggregating with Sum into a single node
- ๐งฉ No expressions needed โ itโs all declarative
This structure is perfect for invoices, order summaries, or reporting payloads where both detail and summary values are needed.
๐ What's coming
Weโre working on official docs to cover:
- All functions including collection (Join, Direct Access, Filter, etc.) that work on repeating nodes
- Behavior of functions inside loops
- Real-world examples like this one
๐ฌ What should we cover next?
Weโre always looking to surface patterns that matter most to how you build.
If thereโs a transformation technique, edge case, or integration scenario youโd like to see explored next โ drop a comment below and let us know. Weโre listening.
๐งก Special thanks to Dave Phelps for collaborating on this scenario and helping shape the walkthrough.