Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with IIF please 1

Status
Not open for further replies.

kofseattle

IS-IT--Management
Nov 19, 2013
1
US
Hello,

I am a newb to SSRS and need some help with an IIF. Can anyone tell me how to achieve this please???

I need to check two date fields, display the first one if it's available, display the second one if the first is not available and if both dates are missing, display a "N/A".

Any assistance appreciated ~ K
 
Any of the 5 expressions below should work. The last one is more readable for me because the conditions are expressed in the positive and there isn't any conditional nesting involved.

Code:
=IIf(Not IsNothing(Fields![red]Date1[/red].Value), Fields![red]Date1[/red].Value, IIf(Not IsNothing(Fields![green]Date2[/green].Value), Fields![green]Date2[/green].Value, "N/A")

=IIf(IsNothing(Fields![red]Date1[/red].Value), IIf(IsNothing(Fields![green]Date2[/green].Value), "N/A", Fields![green]Date2[/green].Value), Fields![red]Date1[/red].Value)

=IIf(IsDate(Fields![red]Date1[/red].Value), Fields![red]Date1[/red].Value, IIf(IsDate(Fields![green]Date2[/green].Value), Fields![green]Date2[/green].Value, "N/A"))

=Switch(Not IsNothing(Fields![red]Date1[/red].Value), Fields![red]Date1[/red].Value, Not IsNothing(Fields![green]Date2[/green].Value), Fields![green]Date2[/green].Value, True, "N/A")

=Switch(IsDate(Fields![red]Date1[/red].Value), Fields![red]Date1[/red].Value, IsDate(Fields![green]Date2[/green].Value), Fields![green]Date2[/green].Value, True, "N/A")
 
The other thing you could consider is in your dataset using a COALESCE on the fields so you can eliminate the IIF on the report
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top