web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Use XPath() to get ave...
Power Automate
Unanswered

Use XPath() to get average

(0) ShareShare
ReportReport
Posted on by 578

Is it possible to use xpath to calculate average? I'm using this expression to sum, and it works perfectly:

xpath(xml(outputs('JSON_Amount')), 'sum(/root/Amount)')

I wonder if there is a way to calculate average. I tried this, but it fails:

xpath(xml(outputs('JSON_Amount')), 'avg(/root/Amount)')

Thanks.

 

 

Categories:
I have the same question (0)
  • Verified answer
    Rhiassuring Profile Picture
    8,690 Moderator on at

    So unless I'm totally off base - and I did research a bit before typing this - there is still no average function in Power Automate. But what you could do is count the amount of items coming out of the XML and then just divide your sum by that.

    I am hoping someone comes in and says "no, rhia, you are wrong, there is a much better way to do this"....

    R

  • emfuentes27 Profile Picture
    578 on at

    Thanks @Rhiassuring. I did a lot of research also, and I arrived to the same conclusion you did. Your recommendation is exactly what I ended up doing. I just calculated the length and divided by the total, outside the xpath

  • PabloD Profile Picture
    62 on at

    You could use sum() and count() in xpath and use that to get the average outside an xpath function.

  • The_Skin Profile Picture
    6 on at

    Just to chime in on this post, for anyone in future that wants to do aggregation style calculations over data sets, take a look at the Advanced Data Operations connector. There’s an Aggregate function that does it nicely.

     

    https://learn.microsoft.com/en-au/connectors/advanceddataoperatio/#aggregate 

  • Rhiassuring Profile Picture
    8,690 Moderator on at

    OooOOOo it's in preview! Thanks, @The_Skin ! Creepy name, but, great tip.

  • The_Skin Profile Picture
    6 on at

    Yeah, fair call. 😂

     

    Also, don’t worry about the preview status, it’s definitely here to stay.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard