Search code examples
reporting-servicesssrs-2008

SSRS IF/Like/Then Expression


I am working on a SSRS report and in this report I have multiple types of accounts for our users. I obviously want to sum the total balance of certain accounts, but since there are multiple I am trying to specify the sum for each of these accounts. Like, AccountTypeA total is ### and AccountTypeB total is ###. I am building an expression but so far this is what I have:

IIF(Fields!AcctNum.Value Like "*.001"), True

I don't know what;s the "else" command when that field is true so it sums the balance I want for each type. Any help would be appreciated; I am new working with SSRS :). Thanks in advance.


Solution

  • To get conditional Sum values (or any other aggregate) you can use an expression like:

    =Sum(IIf(Fields!AcctNum.Value like "*.001", Fields!Balance.Value, Nothing))
    

    This only considers rows that satisfy your first criterion (i.e. certain AcctNum values) for the aggregation.