Mark
Mark

Reputation: 8431

SSRS Report Builder expression error with IIF( ) function

Recently I've encountered an inconsistency with the use of IIF() function in SSRS. I am working on an aggregate function with multiple conditions. Suppose I have this code:

=Sum(IIF(Fields!MATL_STAT.Value="Disposed", Fields!MATL_SIZE.Value,0))

By description, the expression determines the sum of the sizes of the MATL with a MATL_STAT = "Disposed" but everytime I run the report there is an #Error.

My theory is that you can't put fields in the "true option" of IIF() function.

Now, if my theory is correct, is there a workaround for this?

Upvotes: 1

Views: 4970

Answers (2)

Siva Prasad
Siva Prasad

Reputation: 1

you can use Decimal conversion (CDEC) as well reason being the value output is an amount coming in decimals..

Upvotes: 0

Mark
Mark

Reputation: 8431

After an extensive research using builtin function is SSRS reporting services, the field is summing different data types (double/int). To unify the data type, I use CDbl() function like this:

=Sum(IIF(Fields!MATL_STAT.Value="Disposed", CDbl(Fields!MATL_SIZE.Value),CDbl(0.0)))

Upvotes: 1

Related Questions