|
Subject: Re: [xsl] Trying to display Summed Average of Grouped Data From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Mon, 30 Aug 2004 16:55:44 +0100 |
Hi Dom,
> In Brief im trying to display the Averages of each Column for each
> individual Days results so far all the methods ive tried have either
> led to a "0" or the summing of the Entire collection rather than per
> day...i tried using variables but found it impossible to
> manipulate...i fear my xpath knowledge is letting me down ...
It looks as though you're trying to update variables, which of course
you can't do in XSLT. Try this:
<xsl:template match="Log">
<xsl:variable name="LogsForDate" select="key('rows', @Date)" />
<xsl:variable name="Count" select="count($LogsForDate)" />
<table>
...
<tr>
<td bgcolor="#99CCCC">Averages:</td>
<td bgcolor="#cccc99">
<xsl:value-of select="round(sum($LogsForDate/@T_CPU) div $Count)"/>
</td>
...
</tr>
</table>
</xsl:template>
The important thing is that you gather up all the logs for the
particular date in a variable, and then you use the sum() function to
sum whatever you want to sum in order to calculate the average.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Trying to display Summed , Kevin Jones | Thread | [xsl] Multiple matches against keys, Ramon M. Felciano @ |
| Re: [xsl] Trying to display Summed , Kevin Jones | Date | Re: [xsl] sorting titles w stopword, cking |
| Month |