xsl-list
[Top] [All Lists]

Re: Trying to display Summed Average of Grouped Data

2004-08-30 08:55:44
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/



<Prev in Thread] Current Thread [Next in Thread>