Wednesday, March 7, 2012

multiple conditional formatting

Hi,

is there simplier method of doing multiple conditional formating? right now i have to nest the conditional: iif(a=b, "Blue", iif(a=c, "Red", iif(a=d, "Green", "Black"))). so if i have 5/6 or more conditions, it will be very messy.

thanks,
AshIn some cases (e.g. numeric values), you could use alternatives to the IIF function:
* =Choose(...)
http://msdn.microsoft.com/library/en-us/vblr7/html/vafctchoose.asp
* =Switch(...)
http://msdn.microsoft.com/library/en-us/vblr7/html/vafctswitch.asp

In addition, you may want to consider writing a function in custom code (which allows you to define VB functions) or as custom assembly that contains your logic. You can then reuse the function from RDL expressions.

-- Robert|||Why don't you have allow a simple If then else nested statements?|||How do you deal with nested if statements that have multiple conditions for one value. for example if you want to have Country='US' and Month =December and week=1 , then return value 12/01-12/07 and if Country=US, Month=December and week=2 then return value 12/08-12/14 and so on.|||

You can use VB if-then-else statements in the custom code sections by defining a function call, but not directly in an expression. You would then call the function.

Note: iif, choose, switch, etc. can be nested directly in the expression.

-- Robert

|||

You can use logic operators, e.g. =iif(Fields!Country.Value = "US" AND Fields!Month.Value = "December" ... )

-- Robert

No comments:

Post a Comment