SSRS IIF Statement error when passing one of the value from parameters

  • Hello,

    I have SSRS report Parameter name "Audit", under this parameter "Audit" i have drop down(multi valued parameter) so users can select respective value.

    then have a tabular report and the columns related to the each value in the parameter.

    If i select value1 then i should display only related column , if select two values from the parameter my report should display two columns and so onn.

    for that under column visibility property i have selected "show or hide based on an expression" and written for one column

    =IIf(Parameters!audits.Value="Member_Not_available_at_Time_of_Service",True,false)

    "Member_Not_available_at_Time_of_Service" is the value coming from parameter

    I really appreciate and Thanks in advance for Any help.

  • here is the error i am coming. Sorry, i forgot to add error at above. Thanks!

    when i tried above IIF statement i am getting the below error.

    The Hidden expression for the tablix ‘Tablix1’ contains an error: 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'. (rsRuntimeErrorInExpression)

    I really appreciate and Thanks in advance for Any help.

  • A multivalue parameter returns an array type, so it can't be directly compared with a string. You need to use an array method to find the value.

    Try:

    =Array.IndexOf(Parameters!audits.Value, "Member_Not_available_at_Time_of_Service") > -1

    The method will return the 0-based index of the value if it's found in the array, and will return -1 if it is not.

  • Hi Thank very much for your reply .

    i changed my expression to =iif(Array.IndexOf(Parameters!audits.Value, "Member_Not_available_at_Time_of_Service]") > -1,false,true) then it is working as expected. i.e when i select Member_Without_Waiver_Code_as_Time_of_Service from dropdown list column is showing up in the front end and when deselect the value in the drop down column is getting hidden.

    But i have issue when i select "No Audits Selected",then also my column is not showing up because of the above expression in the column level.

    "No Audits Selected" is one value in the drop down list; when i select this i should get all the columns display in the front end which means here i should display "Member_Without_Waiver_Code_as_Time_of_Service" column as well. so i have written expression like this below but i am error as

    At glance : if i select "No Audits Selected" i should get everything(column should display) else depending on column selection i.e;=iif(Array.IndexOf(Parameters!audits.Value, "Member_Not_available_at_Time_of_Service]") > -1,false,true) (its working)

    expression:

    =Switch(Parameters!audits.Value,"No Audit selected",Array.IndexOf(Parameters!audits.Value,"Member_Without_Waiver_Code_as_Time_of_Service") > -1, iif(Array.IndexOf(Parameters!audits.Value, "Member_Without_Waiver_Code_as_Time_of_Service") > -1,false,true))

    Error :(i know this is failing because of conversion error but how to acheive this expression).

    The Hidden expression for the tablix ‘Tablix1’ contains an error: Conversion from type 'Object()' to type 'Boolean' is not valid. (rsRuntimeErrorInExpression)

  • Sorry below is the correct column expression which we discussed earlier and not working. I copied different column in the above expression.

    =Switch(Parameters!audits.Value,"No Audits selected",Array.IndexOf(Parameters!audits.Value, "Member_Not_available_at_Time_of_Service") > -1,iif(Array.IndexOf(Parameters!audits.Value, "Member_Not_available_at_Time_of_Service") > -1,false,true))

    Thank you for any help offered .

  • It's the same issue, you are trying to compare a string to an array, which will not work.

    If you are certain (as you can be) "No Audits selected" will be the first and only value selected in that scenario you could use the index in the parameter to get the first value back i.e. Parameters!audits.Value(0) = "No Audits selected"

    =Switch(

    Parameters!audits.Value(0) = "No Audits selected", False,

    Array.IndexOf(Parameters!audits.Value,"Member_Not_available_at_Time_of_Service") > -1, False,

    True, True

    )

  • It worked for me. Thank you

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

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