How to add a total count column for an expression field

Matt Roberts picture Matt Roberts · Dec 11, 2012 · Viewed 18.4k times · Source

If I have a table (tablix) in SSRS, and one of the columns is a simple expression:

=Fields!NumPorts.Value - Fields!PortsUsedLastQuarter.Value

Then how can I add a "total count" column for this? I can't add a total column, it's greyed out because it's an expression and not a simple field.

Thanks

Answer

Jamie F picture Jamie F · Dec 11, 2012

There are a few different ways to do this. I think the most general purpose way is:

  1. Right click on the grouping that you want to total. Sound like in your case this will be the details group. (You can find a list of groups in the Row Groups pane of the designer window.

  2. Select "Add Total -> Before" (or after)

    You should now have a row to add the totals into. SSRS tries to figure out what totals to insert. If those are appropriate, leave them, but in your case we will need to edit the expression of a cell.

  3. In the cell you want your total, right click and select Expression. (The same process could be followed for a placeholder in the cell as well.)

  4. In the Expression window, Enter =SUM(Fields!NumPorts.Value - Fields!PortsUsedLastQuarter.Value)