0

This is the expression used for calculating the value:

=iif((Sum(CDbl(Fields!RxCount.Value))=0),"0.00",(Sum(Fields!Margin.Value)/Sum(CDec(Fields!RxCount.Value))))

ie:

if Sum(CDbl(Fields!RxCount.Value = 0, result shoul be 0.00 otherwise it should be the divide of two values.

but it display #error when Sum(CDbl(Fields!RxCount.Value = 0 not 0.00

Any help.

Anup Agrawal
  • 6,551
  • 1
  • 26
  • 32
soundarrajan
  • 149
  • 1
  • 3
  • 13
  • 1
    possible duplicate of [Does the iif function compute both paths in SSRS or is it short-circuited?](http://stackoverflow.com/questions/1204179/does-the-iif-function-compute-both-paths-in-ssrs-or-is-it-short-circuited) – Jamie F Feb 11 '14 at 15:36
  • 1
    There are a number of duplicates of this question. Search on `SSRS iif #error` to find many answers pointing at a couple of different workarounds. – Jamie F Feb 11 '14 at 15:37
  • Maybe field Fields!RxCount.Value doesn't return integer/decimal value or value that can be converted to integer. – Konrad Z. Feb 11 '14 at 16:01

1 Answers1

1

You need to test for null values as well, the #Error is likely occurring because

Sum(CDbl(Fields!RxCount.Value)) 

is returning a null value, not a 0.

kyzen
  • 1,579
  • 1
  • 9
  • 13
  • hi kyzen, I use cdec also it display same "#error" result – soundarrajan Feb 11 '14 at 15:49
  • Try this: * Add the RXCount field to a table. * Set a filter on the table to filter out any rows where Fields!RxCount.Value is not null (you can use IsNothing()). * Run the report, look to see how many rows are coming back with nulls. You may be able to just slap an Isnull(RxCount, 0) into your source query if the difference between null (no value) and 0 (a value of 0) don't matter. – kyzen Feb 11 '14 at 15:51