-1

I am trying to run a conditional function in an SSRS expression, that conditionally renders a "-" if any of the fields are empty, and otherwise performs some arithmetic.

The problem is that the control doesn't seem to go to the second condition at all. I am getting the fields in the Report filled with "ERROR".

=IIf(IsNothing(Fields!sales_overall.Value Or Fields!current.Value) = false, 
     "-" , 
     Fields!sales_ overall.Value/Fields!current.Value) 

Can anyone point out what I'am doing wrong here?

Jeroen
  • 60,696
  • 40
  • 206
  • 339
user1597398
  • 131
  • 2
  • 15
  • 1
    Could you tell us what the error is, and help us reproduce your problem (set up some steps to set up your scenario, amongst other things we'll need an example dataset, etc. etc.). It would also help if you could figure out the actual "ERROR" yourself, it probably holds the key to the solution too. Note that you can edit your question to improve it. – Jeroen Apr 29 '14 at 13:52
  • There is no error message when i execute it but only that the fields of the Report are occupied with "#Error" fields. – user1597398 Apr 29 '14 at 13:54

1 Answers1

1

There are two issues, I am seeing.

  1. You don't need to compare isNothing output to false.

  2. SSRS gives #Error because of data type mismatch.

Make sure Sales_Overall and Current value doesn't have commas or anything that makes them text instead of a number.

Try this first

=IIf(IsNothing(Fields!sales_overall.Value) Or ISNothing(Fields!current.Value), 
     "-" , 
     Fields!sales_overall.Value/Fields!current.Value)

If this doesn't work, do the explicit conversion

=IIf(IsNothing(Fields!sales_overall.Value) Or ISNothing(Fields!current.Value) , 
     "-" , 
     CDBL(Fields!sales_overall.Value)/CDBL(Fields!current.Value))

OR

=IIf(IsNothing(Fields!sales_overall.Value) Or ISNothing(Fields!current.Value), 
     "-" , 
     CDEC(Fields!sales_overall.Value)/CDEC(Fields!current.Value))
Anup Agrawal
  • 6,551
  • 1
  • 26
  • 32