cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Aditya_93
Helper I
Helper I

XML xpath expression to get sum

Hi Team,

 

I have been trying to execute an XPath expression in order to get the sum of a few nodes but it returns an "invalid XPath expression"

 

Below is the sample xml 

"<Xavor>

<Dev>
<NewNode1>1234</NewNode1>
<Emp>1</Emp>
<Floor>1</Floor>
<Salary>1200.4</Salary>
</Dev>
<Dev>
<NewNode1>1234</NewNode1>
<Emp>123</Emp>
<Salary>3</Salary>
</Dev>
<Dev>
<NewNode1>1234</NewNode1>
<Emp>3</Emp>
<Salary>1000</Salary>
<Floor>1</Floor>
</Dev>
<Dev>
<NewNode1>1234</NewNode1>
<Emp>4</Emp>
<Salary>3</Salary>
</Dev>
</Xavor>"
 
Xpath query expression I have used:- SUM(Xavor/Dev/Salary)
 
Please help to correct any syntax I have missed.
 
Thanks 
Aditya
3 REPLIES 3
yoko2020
Resolver II
Resolver II

Try this

 

sum(/*/Dev/Salary[string(number(.)) != 'NaN'])

I have tried the above path expression, but it's still giving me error as "invalid XPath expression"

Can you please help me?

Please post the full error message!

 

It seems like PAD only supports retrieving nodes and its attribute values, not calculated values.

So you need to get all desired node values first as a list and then process this list for calculation.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (1,847)