Matt Roberts
Matt Roberts

Reputation: 26897

How to add a total count column for an expression field

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

Upvotes: 4

Views: 20738

Answers (2)

Irf
Irf

Reputation: 4617

why not try with =Sum(Fields!NumPorts.Value - Fields!PortsUsedLastQuarter.Value) as the add total

If it doesn't work then:

First you can try with some field value that doesn't show it the greyed out, then change the value of the column back to your expression
=Fields!NumPorts.Value - Fields!PortsUsedLastQuarter.Value

and the "add total" cell to the expression:
=Sum(Fields!NumPorts.Value - Fields!PortsUsedLastQuarter.Value)

HTH

Upvotes: 3

Jamie F
Jamie F

Reputation: 23789

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)

Upvotes: 5

Related Questions