Reputation: 139
I have a question: I want the average of some numbers. When I have 4 & 2 it says 3, that's correct but when I have 4 & 2.5 it says 14.50 ??
My code
<xsl:value-of select="format-number(round(100*(sum(My numbers) div count(My numbers))) div 100, '##.00')" />
I hope someone can help me.
Thanks!
Upvotes: 1
Views: 53
Reputation: 163625
You've tagged the question XSLT 2.0, so why aren't you using the avg() function?
Upvotes: 1
Reputation: 25942
Confirmed @helderdarocha's comment, your xpath is working fine.
XML
<a><b>4</b><b>2.5</b></a>
XSL
<b><xsl:value-of select='sum(//b) div count(//b)' /></b>
<c><xsl:value-of select="format-number(round(100*(sum(//b) div count(//b))) div 100, '##.00')" /></c>
GIVES
<b>3.25</b>
<c>3.25</c>
Upvotes: 1