SSRS Sum Expression with Condition

Kelvin picture Kelvin · Aug 30, 2013 · Viewed 79.5k times · Source

I have a problem here, Have an SSRS report for Bank Transfer see attached Bank Transfer Per Bank

I would like to add a row expression which will Sum the total amount of the same bank, i.e, 03001 - Standard Chartered Bank Ltd BJL, 03002 - Standard Chartered Bank Ltd sk and 03002 - Standard Chartered Bank Base are all standard charters, i would like to get a total of all standard charters GMD figures. if need more clarification, please ask.

NB: Banks which are together e.g Standard charters above have a common field called BankAName. So the sum condition can be set to check if BankAName is the same.

Answer

Ian Preston picture Ian Preston · Aug 30, 2013

You'll need something like this:

=Sum(IIf(Fields!BankAName.Value = "Standard Chartered Bank"
    , Fields!Amount.Value
    , Nothing)
  , "DataSet1")

This checks for a certain field (e.g. BankAName), and if it's a certain value that row's Amount value will be added to the total - this seems to be what you're after. You may have to modify for your field names/values.

By setting the Scope of the aggregate to the Dataset this will apply to all rows in the table; you can modify this as required.