You haven't shown the output you want, but if you want a total across activities, then I wouldn't expect to be computing it while processing an individual activity. I would expect to see something like
<xsl:template match="Records">
<total activity="{$param}">
<xsl:value-of select="sum(Activity[ServiceType=$param]/TotalHours"/>
</total>
</xsl:template>
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference