top of page
  • Writer's pictureSofia Ng

Calculations in Power Automate / Logic Apps

Updated: Oct 19, 2023

While we have expressions in Logic Apps and Power Automate they are limited in terms of what we can do with them. This blog post aims to give more options to how we deal with numerical values in our automation.

Xpath has been around for a very long time and, if you have worked with SQL Server and T-SQL xpath has been very helpful. You can use the power of xpath in low code automation such as logic apps and power automate as well, so lets get into it.

For this blog we have used Power Automate however the same building blocks can be used in a Logic App both consumption and standard.

For a data source we use a simple list I have created in SharePoint. This could be any number of sources such as an API call, an excel spreadsheet etc.

Retrieve your data into the flow, for this example we use a Get items action

Create an array variable to store the values which we will retrieve.

Now to iterate through the list and populate the variable with the Coffee count, use an append to array variable action

Now we get to the part which will make things a wee bit easier, add a compose action and create an XML as per below:

Test running the flow now will give an output of a simple array with numbers.

Add another compose action and specify that this is indeed XML

The data remains the same however it is now highlighted as per XML syntax.

Now we can use xpath and the available functions (reference document:

For our example we will make use of the sum function.

Add another Compose action and add the following: xpath(outputs('Compose_2'),'sum(/root/Num)')

Run your flow/logic app to test

Voila! The total number of coffees had in a week is 16 which nicely matches our entries in our list

Using xpath opens up an array of calculation methods and is another tool for your toolbox.

Reach out to us on our contact us page if you have any questions or would like to have a chat about how your business can benefit.

Recent Posts

See All


bottom of page