pramod
pramod

Reputation: 11

How to multiply only not null values in rdlc report expression

How to multiply two values if not null in RDLC report expression

I was using this

=SUM(Fields!Quantity.Value*Fields!ExclusivePrice.Value)

changed to this, but still getting error if value is null

=Sum((IIf(Fields!Quantity.Value Is Nothing, 0,Fields!Quantity.Value))*(IIf(Fields!ExclusivePrice.Value Is Nothing, 0,Fields!ExclusivePrice.Value)))

Thanks in advance for the help.

Upvotes: 0

Views: 2827

Answers (1)

tezzo
tezzo

Reputation: 11115

You have to convert every possible values to the same type (CDec for Decimal, CDbl for Double, etc.) before aggregation.

For example you can modify your expression like this:

=Sum(IIf(Fields!Quantity.Value Is Nothing, CDec(0), CDbl(Fields!Quantity.Value)) * IIf(Fields!ExclusivePrice.Value Is Nothing, CDbl(0), CDec(Fields!ExclusivePrice.Value)))

This is the 'compressed' version:

=Sum(IIf(Not IsNothing(Fields!Quantity.Value * Fields!ExclusivePrice.Value), CDbl(Fields!Quantity.Value * Fields!ExclusivePrice.Value), CDbl(0)))

Upvotes: 1

Related Questions