Search This Blog

IIF or IF Else in SSRS with Examples

IIF or IF Else in SSRS with Examples

Many times in your Report you have to Show Data Based on Some Condition which is like IF ELSE in other Programming Language .
In SSRS you don't have to write else condition within  IFF only you have to define what you want to do if condition satisfy and what if condition doesn't Satisfy.

Syntax eg

=iif(Fields!TaskIsCritical.Value like "True","Y", "N")

Field is the value of ur Data field

In the above iif condition  it will check wheather the TaskIsCritical which is a bit field is True or Not 
If it's true it will Display Y in the text Box else N.

if you want to check two condition like taskiscritical is true and Sumofcost >10000 then Y else N

you can write expression like below

=iif(Fields!TaskIsCritical.Value like "True" and  Sum(Fields!Cost.Value)>10000 ,"Y", "N")

In above IiF condition you are checking two conditon it will show Y in your TextBox only when 
Taskiscritical field value is true and Sum of cost is greater than 10,000.

In order to apply conditional formating in your Text Box like if  Cost is greater than 1000 then Tex box text color should be green else black.


Select your TextBox-Go to Text Box Properties-Right Hand in Solution Explorer

Select Color Properties-Expression write

 =Iif(ReportItems!Cost.Value > .1, "Green", "Black")

Note:In order to appply multiple if condition you can use switch Statement in SSRS.




2 comments: