Click here to Skip to main content
15,903,744 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I want to write an expression like this.

If(a/b)-1 > 3 display "red" or (a/b)-1 < (-3) display "green"

in ssrs. I dont want to use switch for this. Pls help.
Posted

1 solution

Try using the Switch function.
Here is an example
http://www.bidn.com/blogs/ChrisAlbrektson/bidn-blog/1478/ssrs-switch-function-examples[^]

Edit:
If using Switch function is not an option, you can use nested If as shown below.
IF(Parameter=2,IF((a/b)-1)>3,"red",IF((a/b)-1)>(-3),"Green","")),
  IF(parameter=3,IF((a/b)-1)>0,"red",IF((a/b)-1)<0,"green","")),"")
)
 
Share this answer
 
v2
Comments
Dhivya.J 26-Dec-12 5:03am    
Hi I want to include this expression in another iif condition.. so i cant able to use switch for this. thank you. Any other suggessions??
__TR__ 26-Dec-12 5:20am    
Try
IIF(2 > 1 AND ((a/b)-1 > 3),"red", IIF(2 > 1 AND (a/b)-1 < (-3) ),"green",""))
Replace 2 > 1 with your expression.
Dhivya.J 26-Dec-12 6:49am    
Thank you. But my expression is like this

IF(Parameter=2, I hav to check both conditions like ((a/b)-1)>3, "red" and ((a/b)-1)>(-3),"green")

or if (parameter=3, if((a/b)-1)>0, "red" and ((a/b)-1)<0, "green" )

Pls suggest...
__TR__ 26-Dec-12 8:46am    
Try
IF(Parameter=2,IF((a/b)-1)>3,"red",IF((a/b)-1)>(-3),"Green","")),
IF(parameter=3,IF((a/b)-1)>0,"red",IF((a/b)-1)<0,"green","")),"")
)
Dhivya.J 26-Dec-12 9:15am    
Hi
Why dont you post this as a solution. Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900