Power Community

Power Community

One Minute Fixes – Summing up a field

There is an unlikely expression that can sum up any field/key in an array, and that’s the XPATH expression. The XPATH allows you to sum up any level of the array, it does require the json array to be converted to xml, but we have the XML expression for that.

The whole process is 3 steps

  1. ‘Select’ to create and array of the numbers,
  2. ‘Compose’ to create a xml compliant object (root/fieldName).
  3. And finally a ‘Compose’ / ‘Set_variable’ to store the sum in by converting it to an xml and using xpath.


The final expression converts the object into XML and then uses the XPATH expression.

xpath(xml(outputs('ComposeConvert')), 'sum(/root/number)')

Xpath can do Min,Max,Average,Count as well as Sum. It can also use And/Or operators to filter cross fields, and much more.

This is a series of short blogs designed to help find solutions for random problems before you ask, keep your eyes out for more

l also do long form and broader Power Platform blogs here https://dev.to/wyattdave

This post was originally published on this site

- Advertisement -spot_img


Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

July 2024 update of Power Automate for desktop

We are happy to announce that the July 2024 update of Power Automate for desktop (version 2.46) has been...

More Articles Like This

- Advertisement -spot_img