I'm trying to produce a conditional sum in SQL Server Report Builder 3.0.
My expression looks like this:
=Sum(Iif(Fields!ProjectTypeID.Value=2,Fields!kWp.Value,0))
I'd hoped that this expression would produce a sum of the kWp of all projects of type 2.
Unfortunately, it is not to be. And I can't seem to work out why. It just returns a 0 result, even though I know that there are non-zero values in the kWp column, and the column does not contain nulls.
A colleague did manage to get a positive result by replacing the
Fields!kWp.Value
with
1 * Fields!kWp.Value
But we have no idea why this works, and therefore, can't really trust the answer.
How can I get this conditional sum to behave itself?