I am trying to calculate totals based on a specific ID as well as YTD. I've looked everywhere and can't seem to figure out the solution. The XML doc looks similar to this:\[code\]<pay> <pay_year year="Year-2011"> <paycheck date="Jun-20-2011"> <hours> <hours_type HID="Reg" qty="38.75" pay="1115.25"/> </hours> </paycheck> <paycheck date="Jul-05-2011"> <hours> <hours_type HID="Reg" qty="76.21" pay="2193.60"/> <hours_type HID="Hol" qty="7.75" pay="223.07"/> </hours> </paycheck> <paycheck date="Jul-20-2011"> <hours> <hours_type HID="Reg" qty="76.21" pay="2193.60"/> <hours_type HID="Sic" qty="7.75" pay="223.07"/> </hours> </paycheck> </pay_year></pay>\[/code\]The XSLT I'm using is:\[code\]<xsl:template match="hours"> <xsl:apply-templates select="hours_type"> <xsl:sort order="descending" /> </xsl:apply-templates><tr> <th class="sub" colspan="" align="justify">Subtotal / Totals YTD</th> <td class="sub"><xsl:value-of select="sum(hours_type/@qty)" /></td> <td class="sub"><xsl:value-of select="format-number(sum(preceding:aycheck/hours/hours_type/@qty) + sum(hours_type/@qty), '###,###.##')"/></td> <td class="sub"> <xsl:value-of select="format-number(sum(hours_type/@pay), '$###,##0.00')" /> </td> <td class="sub"> <xsl:value-of select="format-number(sum(preceding:aycheck/hours/hours_type/@pay) + sum(hours_type/@pay), '$###,##0.00')"/> </td></tr></xsl:template><xsl:template match="hours_type"><xsl:if test="position()=1"><xsl:apply_templates select="@qty" /><!--Not Sure how to make this work here --><xsl:apply_templates select="@pay" /><!--Not Sure how to make this work here --></xsl:if><xsl:if test="position()=2"><xsl:apply_templates select="@qty" /><!--Not Sure how to make this work here --><xsl:apply_templates select="@pay" /><!--Not Sure how to make this work here --></xsl:if><xsl:if test="position()=3"><xsl:apply_templates select="@qty" /><!--Not Sure how to make this work here --><xsl:apply_templates select="@pay" /><!--Not Sure how to make this work here --></xsl:if></xsl:template><xsl:template match="@qty|@pay"><td align="justify"><xsl:value-of select="." /></td></xsl:template>\[/code\]The output would look something like this in html:\[code\]Date---------Hours Type-----------Qty-----YTD-------Amount-----Pay YTDJun-20-2011--Reg------------------38.75---38.75-----1115.25----1115.25Subtotal--------------------------38.78---38.75-----1115.25----1115.25Jul-05-2011--Reg------------------76.21---114.96----2193.60----3308.85-------------Hol------------------7.75----7.75------223.07-----223.07Subtotal--------------------------83.96---122.71----2416.67----3531.92Jul-20-2011--Reg------------------76.21---191.17----2193.60----5502.45-------------Sic------------------7.75----7.75------223.07-----223.07Subtotal--------------------------83.96---198.92----2416.67----5725.52\[/code\]I can get the Subtotal line just fine, the problem is I can't get the inline YTD totals by specific ID. I may be making this a lot harder than it is.