Link to home
Start Free TrialLog in
Avatar of Daniel Trocker
Daniel TrockerFlag for Norway

asked on

SSRS: show empty field if the logical test is false

Hi,

I am using the "iif"-function in SSRS. How is it possible to show nothing, if the logical test is wrong?

I.e.
IIf(Parameters!totaldager.Value=0,Parameters!FVDager.Value,"")

I am getting the right values if the logical test is true, but I am just getting #Error - messages if it is false.

Any suggestions are much appreciated.

Thanks
Daniel
Avatar of Russell Fox
Russell Fox
Flag of United States of America image

It's likely that your initial parameter is NULL or something, but you can use the ISERROR function to smooth it out:

IIF(IsError(IIf(Parameters!totaldager.Value=0,Parameters!FVDager.Value,"")) = 1, "", IIf(Parameters!totaldager.Value=0,Parameters!FVDager.Value,""))

Open in new window

Avatar of Daniel Trocker

ASKER

Hi Russell,

I am still getting the #Error-message when taking your formula. Isn't there a possibility to format the fields with "#Error", such that they are transparent or white?

Thank's in advance.
Daniel
My guess is a type mismatch.  Is "Parameters!FVDager.Value" supposed to be a numeric value?  If so, you will want to convert that expression to a character string so that both possible output values are of the same type, in this case a string value.
I agree with @larryh, above. You're saying "if this is the number zero, input the string <empty string>.
IIf(Parameters!totaldager.Value=0,Parameters!FVDager.Value,"")

Open in new window

You might be better off sticking with numeric values:
IIf(Parameters!totaldager.Value=0,Parameters!FVDager.Value,0)

Open in new window

And then, as you suggest, change the text color to a dynamic value, something like
IIf(TextBox123.Value=0, "White", "Black")

Open in new window

Hi again,
thank you all for your comments. After playing around with the formulas I noticed the following:

1. All the formulas work, if I set them up like this (the decisive part is the "2" at the end.
=IIf(Fields!budsjett.Value=0,"",Fields!Oms_inkl_samlefak.Value/2)

2. If I substitute the "2" with a "Field!Name.Value", SSRS gives an #Error-message and I am also not able to change color in the formatting in order to hide the #Error.

BR
Daniel
Supplement to my previous comment:

"IIf(Fields!budsjett.Value=0,"",Fields!Oms_inkl_samlefak.Value/Fields!Budsjett.Value)" does not work.
ASKER CERTIFIED SOLUTION
Avatar of larryh
larryh
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial