SSRS expression switch/Else if

  • So i've been messing around with this all morning and i just can't quite figure it out. I have a parameter that can be one of two values. Either I or P.

    So i need the title on the report to say one thing when I is chosen, one thing when P is chosen, and one thing when both are chosen (this is a multi select parameter)

    This is what i currently have but it keeps coming up with #Error.

    =Switch(Parameters!clmType.Value = "P","List of Professional Paper Claims ", Parameters!clmType.Value = "I","List of Institutional Paper Claims ", Parameters!clmType.Count > 1 ,"List of Professional & Institutional Paper Claims ")

    I've also tried this

    =Switch(Parameters!clmType.Value = "P","List of Professional Paper Claims ", Parameters!clmType.Value = "I","List of Institutional Paper Claims ", Parameters!clmType.Value = "P" and Parameters!clmType.Value = "I" ,"List of Professional & Institutional Paper Claims ")

    Thanks!!

    EDIT: Also would using a nested IIF work? not sure what that would look like, or the order of it.

    Tried using this as a Nested IIF and still getting a #Error

    =IIF(Parameters!clmType.Count > 1,"List of Professional & Institutional Paper Claims ", IIF(Parameters!clmType.Value = "P","List of Professional Paper Claims ","List of Institutional Paper Claims "))

    I know it partially works because i used this and it worked as expected

    =IIF(Parameters!clmType.Count > 1,"List of Professional & Institutional Paper Claims ", "only one picked")

  • avitale (7/20/2011)


    So i've been messing around with this all morning and i just can't quite figure it out. I have a parameter that can be one of two values. Either I or P.

    So i need the title on the report to say one thing when I is chosen, one thing when P is chosen, and one thing when both are chosen (this is a multi select parameter)

    This is what i currently have but it keeps coming up with #Error.

    =Switch(Parameters!clmType.Value = "P","List of Professional Paper Claims ", Parameters!clmType.Value = "I","List of Institutional Paper Claims ", Parameters!clmType.Count > 1 ,"List of Professional & Institutional Paper Claims ")

    I've also tried this

    =Switch(Parameters!clmType.Value = "P","List of Professional Paper Claims ", Parameters!clmType.Value = "I","List of Institutional Paper Claims ", Parameters!clmType.Value = "P" and Parameters!clmType.Value = "I" ,"List of Professional & Institutional Paper Claims ")

    Thanks!!

    EDIT: Also would using a nested IIF work? not sure what that would look like, or the order of it.

    Try this variation of your first expression:

    =Switch(Parameters!clmType.Value = "P","List of Professional Paper Claims ", Parameters!clmType.Value = "I","List of Institutional Paper Claims ", True,"List of Professional & Institutional Paper Claims ")

  • Try this variation of your first expression:

    =Switch(Parameters!clmType.Value = "P","List of Professional Paper Claims ", Parameters!clmType.Value = "I","List of Institutional Paper Claims ", True,"List of Professional & Institutional Paper Claims ")

  • Daniel, i'm still getting an error using your code

    Just FYI, this is the error i'm getting:

    Overload resolution failed because no Public '=' can be called with these arguments:

    'Public Shared Operator =(a As String, b As String) As Boolean':

    Argument matching parameter 'a' cannot convert from 'Object()' to 'String'.

  • Sorry I forgot this is a multi value parameter, they don't hold data the same as a single value parameter, so these comparisons will fail.

    I can't really test this, but I think you need something like this:

    =IIF(InStr(JOIN(Parameters!clmType.Value,","),"P") > 0,IIF(InStr(JOIN(Parameters!clmType.Value,","),"I") > 0,"List of Professional & Institutional Paper Claims ", "List of Professional Paper Claims "),"List of Institutional Paper Claims ")

    Doulbe check I got the ( and the ) in the right places and the right quantity, it is hard to do this without the expression editor.

  • This works perfectly! thanks so much!!!

Viewing 6 posts - 1 through 5 (of 5 total)

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