In this blog, we walk through real-world scenarios and provide downloadable samples so you can try it yourself and accelerate your integration workflows.
Continuing our exploration of the Logic Apps Data Mapper, let's uncover how you can effortlessly calculate Minimum, Maximum, and Average values from repeating nodes. Many users may not yet realize these handy built-in functions exist—let's reveal their power!
🧾 Scenario: Temperature data analysis
Imagine you're managing environmental monitoring stations across multiple regions, and you need accurate insights to proactively respond to weather events. Quickly determining the minimum, maximum, and average temperatures from hourly readings can help predict extreme weather, prevent environmental hazards, and optimize resource allocation.
📌Try it Out Yourself!
You can easily test these scenarios using our sample schemas available on our GitHub repository.
Here's how to set them up:
- Place sample schemas into your Artifacts folder.
- Place the Data Mapper file (.lml) into the Map Definitions folder. You can then directly right-click and load the map into your VS Code.
📸Loading data map by right-clicking .lml file
-
Place the XSLT map file (.xslt) into your Maps folder.
We are actively expanding our library of examples and encourage you to contribute your own schemas or patterns through a pull request. Help us build a comprehensive set of samples for the entire community!
🔧 Step-by-step walkthrough
1. Identifying your repeating node 🔄
To leverage these functions, first identify the repeating node in your schema. These are parent nodes that typically have property MinOccurs > 1. For our scenario, let's consider temperature data recorded hourly. Lets take a look at both the repeating node on source and non-repeating node at destination. The repeating node is indicated by A1,A2 🔄
📸 WeatherReport repeating node on source
📸 Day2 node on destination
2. Calculating minimum temperature ❄️
To determine the lowest temperature:
- First, convert the Temperature node from Decimal to Integer using the built-in conversion function. Click Functions ➡️ Conversion ➡️ To Integer.
📸 To Integer function for Minimum calculation
- With the data normalized, select Functions ➡️ Collection ➡️ Minimum.
- Map your To Integer function into the Minimum function.
- Then, drag your WeatherReport node into the Minimum function.
📸 Inputs to Minimum function
📸 Screenshot: Minimum function configuration
- Direct the output from the Minimum function to your Temperature destination node.
📸 Map setup for Minimum
- Test your map using a sample source schema containing multiple values in the WeatherReport node.
📸 Test output for Minimum
3. Finding maximum temperature ☀️
To find the highest temperature:
- Convert Temperature node from Decimal to Integer using a built-in function the same way we did in the previous step
- Now that we have the data normalized, it is time to calculate the maximum temperature. Navigate to Functions ➡️ Collection ➡️ Maximum
- Map your To Integer function into the Maximum function
- Then, drag WeatherReport node into the Maximum function
📸 Inputs to Maximum function
📸 Maximum function configuration
- Direct the output to Temperature destination node from Maximum function.
📸 Map setup
- Test the map with sample source schema that has multiple values for WeatherReport node
📸 Test output for Maximum
3. Calculating Average Temperature 🌤️
To calculate the average temperature:
- Start by converting the Temperature node from Decimal to Integer using the built-in conversion function. Navigate to Functions ➡️ Conversion ➡️ To Integer.
- Next, select Functions ➡️ Collection ➡️ Average to calculate the average temperature.
- Map your To Integer function into the Average function.
- Additionally, drag the WeatherReport node into the Average function.
📸 Inputs to Average function
📸 Average function configuration
- Convert the output from Average function to Integer
- Finally, direct the output from the Average function to your Temperature destination node.
📸 Map setup for Average
- Verify your mapping by testing with a sample schema containing multiple temperature values.
📸Test output for Average
Related content
💬 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.