Multiple Values in IIF Statement

  • Guys, I'm trying to write an expression for Visibility feature.

    It works fine when I write something like this:

    =IIF(Parameters!CodeToDrillDown.Value = 1, TRUE, FALSE)

    The users have a range of values to choose from, for instance, codes 1 through 99.

    If I write a statement like: =IIF(Parameters!CodeToDrillDown.Value = 1 or 3 or 7 or 11 or 12 or 16 or 25 or 44 or 99, TRUE, FALSE) ...it bombs.

    I tried switching the parameters' data type from interger to text and viceversa, but I get the same results.

    Any assistance on how to write the code correctly?

    Thanks for the help.

  • 360Addict (11/10/2010)


    Guys, I'm trying to write an expression for Visibility feature.

    It works fine when I write something like this:

    =IIF(Parameters!CodeToDrillDown.Value = 1, TRUE, FALSE)

    The users have a range of values to choose from, for instance, codes 1 through 99.

    If I write a statement like: =IIF(Parameters!CodeToDrillDown.Value = 1 or 3 or 7 or 11 or 12 or 16 or 25 or 44 or 99, TRUE, FALSE) ...it bombs.

    I tried switching the parameters' data type from interger to text and viceversa, but I get the same results.

    Any assistance on how to write the code correctly?

    Thanks for the help.

    I have struggled with an OR based Iif in the past also. I don't remember what my solution was, but here are a couple of ideas.

    First I think you need to use the complete expression in between your OR like

    Parameters!CodeToDrillDown.Value = 1 OR Parameters!CodeToDrillDown.Value = 3 OR Parameters!CodeToDrillDown.Value = 7 etc.

    If that doesn't work try to use a SWITCH statement. Switch is a great replacement for a series of nested IIFs. It is just a series of repeating expressions and response values, it will return the response of the first true expression. Like this:

    =SWITCH(Parameters!CodeToDrillDown.Value = 1, True,Parameters!CodeToDrillDown.Value = 3, True,Parameters!CodeToDrillDown.Value = 7, True.....etc)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply