简体   繁体   中英

SSRS Expression Field with Multi-value parameter embedded in IIf Statement

I am working on creating an expression to check the value of a parameter and then display a text field based upon the value of the passed in parameter. Here is my current code

=IIf(Parameters!AssessmentType.Count = 3, "All Assessments",
IIf(Parameters!AssessmentType.Count = 2, IIf(Parameters!AssessmentType.Value(0) = 2 AND 
Parameters!AssessmentType.Value(1) = 3, "Initial and Review Assessments", 
IIf(Parameters!AssessmentType.Value(0) = 2 And Parameters!AssessmentType.Value(1) = 4, 
"Initial and Closing Assessments", IIf(Parameters!AssessmentType.Value(0) = 3 
And Parameters!AssessmentType.Value(1) = 4, "Review and Closing Assessments", 
IIf(Parameters!AssessmentType.Value(0) = 3 And 
Parameters!AssessmentType.Value(1) = 2, "Initial and Review Assessments", 
IIf(Parameters!AssessmentType.Value(0) = 4 And Parameters!AssessmentType.Value(1) = 2, 
"Initial and Closing Assessments", IIf(Parameters!AssessmentType.Value(0) = 4 
And Parameters!AssessmentType.Value(1) = 3, "Review and Closing Assessments","")))))), 
IIf(Parameters!AssessmentType.Count = 1, IIf(Parameters!AssessmentType.Value(0) = 2, 
"Initial Assessments", IIf(Parameters!AssessmentType.Value(0) = 3, "Review Assessments", 
IIf(Parameters!AssessmentType.Value(0) = 4, "Closing Assessments", ""))), "")))

The parameter has specified values of 2, 3, and 4. As well as being a multi-valued parameter. The parameter is also involved in a filter expression for the main dataset.

The current expression works for having all three parameter values selected as well as having any two parameter values selected, however, whenever a single parameter value is selected, an undefined error is returned. The expression is sitting in the header of my report and does not allow for any trouble/bug fixing as the error type is not defined.

Any help is always appreciated!!

I ended up just using three different text boxes with visibility expressions to sort out the display. Everything works now.

Assuming that your parameters labels are "Initial", "Review" and "Closing" liek this...

在此处输入图片说明

Then you could simply do this...

= IIF(
        Parameters!AssesmentType.Count = 3,
        "All",
        JOIN(Parameters!AssesmentType.Label, " and ") 
    )
    & " Assesments"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM