2-Value Multivalue Parameter, "in" function and "all selected"

So I have a very simple multivalue parameter that has two values

Value A
Value B

I have an ifelse calculated field and if I want to know if JUST value A is selected or value B is selected then I can produce a result. However, if Neither or Both are selected I can only get the calculated to calculate as if either all or neither are selected i.e. it either shows the value of neither even if both are selected or it shows the value of both if neither are selected.

It seems that:

ifelse(in(“Value A”, {$mvparameter}) AND in(“Value B”, {$mvparameter}), 1, 0)

Always evaluates to false even if both are selected but

ifelse(in(“Value A”, {$mvparameter}) , 1, 0)

works fine as long as only value A is selected.

This leads me to conclude that if both are selected then the mv parameter control returns something other than an array with all the values in it. I need the calculated field to return differently depending if one value, or the other value, or both, or none are selected.

1 Like

So I fixed this. In case anyone else has the same problem.

You have to first ifelse(in(NULL, $mvparameter), 1 (or true value), [other cases in ifelse statements])

i.e. you test to see if all values are selected first and return a positive if all of them are. Then assess for other cases i.e. one of the parameters is selected (remember my case only has 2 alternatives, not sure what you do if more than 2) and once you’ve determined that:

Both Value A AND Value B Selected = false
AND
Value A Selected = false
AND
Value B Selected = false
THEN
Must be true neither are selected so return 0 (false value)

Hope that helps someone.

1 Like

Thank you so much for this, saved me a lot of time. I wish I could find somewhere in the documentation that explicitly mentions this behavior of the in() function, where it ‘returns’ NULL if all are selected, and returns… something else? when none are.