top of page
  • Gold-Service partner
  • LinkedIn

Calculations in Power Automate / Logic Apps

  • Writer: Sofia Ng
    Sofia Ng
  • Jul 29, 2022
  • 2 min read

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.


ree

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.

ree

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.


ree

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


ree

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


ree

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


ree

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:


ree

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


ree

Add another compose action and specify that this is indeed XML


ree

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


ree

Now we can use xpath and the available functions (reference document: https://developer.mozilla.org/en-US/docs/Web/XPath/Functions


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)')


ree

Run your flow/logic app to test

ree

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

ree

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.

Gold medal Make Partner

Contact Us

QUESTIONS?

WE'RE HERE TO HELP

  • LinkedIn

© 2023 by Ava Technology Solutions. Proudly created with Wix.com

bottom of page