I am trying to give the below expression for font color in ssrs:
=IIF(Fields!A.Value<>0 AND Fields!P.Value <>0, IIF(Fields!A.Value >= Fields!P.Value, "Green", "Red"), "Black")
It works fine for all the numbers except when Either of A or P is 0 I am getting both A and P as Black.
Basically, All I want is:
- When A = P = 0 Black
- When A >= P (for eg. say both are 5) then Green
- When A < P Red
The IIF syntax did not work as I expected i.e. When I have 0 in P and 5 in A then the font color should be green and the vice versa should be red.
I have to work a way around to get what I want with Switch statement.
=Switch(Fields!A.Value>=Fields!P.Value and (Fields!P.Value<>0 AND Fields!P.Value <>0), "Green",
(Fields!A.Value = 0 and Fields!P.Value =0), "Black",
(Fields!A.Value=0 AND Fields!A.Value < Fields!P.Value), "Red",
(Fields!P.Value = 0 AND Fields!A.Value > Fields!P.Value), "Green")
Can someone explain to me why my IIF statement did not work please?
Your help is much appreciated. Thank you.