Search code examples
reporting-servicesssrs-2008

ssrs sum group totals for specific groups and subtract for specific groups


I have a report like this:

Expenses SSRS report

I have grouped on group name called expense type. Ideally expense type has three types, 1, 2 and 3. I have used them to sum up in TOTAL in blue line.

Now I want to add the total of totals to brown tan line,

I want ( (total of group 1 + total of group 3 ) - total of group 2 ) in the tan color total billing submitted.

Can anyone help me in writing this expression?


Solution

  • Use IIF() or SWITCH() to check the Category of each value before you calculate the totals.

    =(Sum(IIF(Fields!ExpenseCategory.Value = "Group 1", Fields!Amount.Value, nothing))
    + Sum(IIF(Fields!ExpenseCategory.Value = "Group 3", Fields!Amount.Value, nothing)) )
    / Sum(IIF(Fields!ExpenseCategory.Value = "Group 2", Fields!Amount.Value, nothing))