Sunday, February 19, 2012

iif expression...need to add another condition...

Ok,
This expression for the font color is great:
=IIf(Fields!Purchase.Value < 0, "Red", "CornflowerBlue")
It changes negatives to red, positives to CornflowerBlue.
However, I need 0 (zero values) to be White, so that there is the third
color.
Any help is appreciated.
Thanks,
TrintMy only suggestion is to have a nested "iff" I do this quite a bit.
=IIf(Fields!Purchase.Value < 0, "Red", IIF(Fields!Purchase.Value = 0,
"White","CornflowerBlue"))
Hope that works.
"trint" wrote:
> Ok,
> This expression for the font color is great:
> =IIf(Fields!Purchase.Value < 0, "Red", "CornflowerBlue")
> It changes negatives to red, positives to CornflowerBlue.
> However, I need 0 (zero values) to be White, so that there is the third
> color.
> Any help is appreciated.
> Thanks,
> Trint
>|||You might find it easier to maintain with this kind of approach:
=getPurchaseColour(Fields!Purchase.Value)
... and have a function like this (pseudocode)..
friend function getPurchaseColour(value) as string
if value<0 return "Red"
if value=0 return "White"
return "CornflowerBlue"
end function

No comments:

Post a Comment