Sunday, March 25, 2012

Comparing multiple values in an iif clause

Hello,

Just want to ask..

Does anyone have an idea how i can compare multiple values in the iif() clause like

IDType IN (1, 2, 3, 4)

This one doesnt work

iif(IDType IN (1, 2, 3, 4), true, false)

Please help..

Thanks..

One option is to use an IIF function call like this:

=iif(Fields!IDType.Value = 1 OR Fields!IDType.Value = 2 OR Fields!IDType.Value = 3 OR ..., true, false)

In 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

-- Robert

No comments:

Post a Comment