Link to home
Start Free TrialLog in
Avatar of newjeep19
newjeep19Flag for United States of America

asked on

SSRS Expression how to check for a NULL value

I have an SSRS report where a textbox on the report either shows or hides data based on wheather a checkbox is checked on an application. The issue that I have is that the expression is not showing the textbox when the checkbox has been checked.
My expression is below:
=IIF(IsNothing(Fields!gtri_maintenanceid.Value), First(Fields!gtri_maintenanceid.Value) & vbCrLf & First(Fields!ServiceSupportRepPhone.Value)  & vbCrLf & First(Fields!ServiceSupportRepEmail.Value),"")

gtri_maintenanceid is the field on the application that determines if the textbox on the report is displayed or not. The maintenance id is a lookup value that if not null on the application is converted to a boolean value reflecting that it is or is not checked.
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

Try this..

=IIF(Trim(Fields!gtri_maintenanceid.Value)=""), Fields!gtri_maintenanceid.Value & vbCrLf & Fields!ServiceSupportRepPhone.Value  & vbCrLf & Fields!ServiceSupportRepEmail.Value,"")

I would not use First. This will only return the first record in that field.
Avatar of newjeep19

ASKER

Thank you for the response, however, the textbox is still not visable.
Have you verified that your dataset is producing the correct answer to the report?
yes
You will have to piece together your expression to test it.
first have all the textboxes un-hide so you can see what is coming to the report.
then add the other piecses as you get the right answer.
In addition to what planocz mentioned: add a couple of additional columns to your tablix for testing purposes.  Here's what to put in them:

First new col: =Fields!gtri_maintenanceid.Value
Second: =Len(Fields!gtri_maintenanceid.Value)

You can use the Len function Instead of using IsNothing, though IsNothing should normally work as well.  With Len, your expression would be something like =IIF(Len(Fields!gtri_maintenanceid.Value) = 0, <no maintenance ID>, <maintenance ID exists>)

(replace <...> placeholders with valid expression)

Also, your expression doesn't make a lot of sense.  Basically (and simplified) it says to display the maintenance ID when there is none.  Shouldn't it be the other way around?
ASKER CERTIFIED SOLUTION
Avatar of Howard Cantrell
Howard Cantrell
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