Home Forums Reporting Services Reporting Services Use a CTE to calculate running total instead of using the SSRS function? RE: Use a CTE to calculate running total instead of using the SSRS function?

  • If you have 2012, then there's some "new" functionality in the SUM() OVER fuction that will do this nicely for you.

    If you have 2008 or 2005, then a recursive CTE (rCTE) would certainly solve the problem... kind of like a WHILE loop or cursor solves the problem. Still, that's probably ok for the normally small number of rows that are in such reports.

    I'd recommend steering clear of "Triangular Joins" even if there are very few rows. See the following link for why.

    [font="Arial Black"]Hidden RBAR: Triangular Joins[/font][/url]

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)