Multiple Value Parameter Default Value list not working in calculated field

I’m using a multi-value parameter - cohortIDs - to hold a list of entity ids to create a filtering cohort. A calculated field sets an “in cohort flag” for each entity on the list.

in({patient_id}, ${cohortIDs})

This works very well when selecting ids from a drop down parameter input control. I can add 100 or 1000 ids to the cohortIDs parameter and then filter for entities with ‘in cohort flag’ = 1.

So, I’d like to pre-populate the parameter with a list of ids based on user. I set the dynamic default for cohortIDs to a single field with multiple ids in the form “1234, 1235, 1236, 1239, …”

This appears to work in that the parameter control becomes populated with the correct list of ids, but the field calculation only acts on the last id in the list.

It seems that the parameter contains all the values, but acts as a single value parameter in the calculation. Is there some other way to load a multiple value parameter with multiple values besides hand selecting each value with the parameter drop down control?

NOTE: the data shown below is entirely synthetic.

Hello @aswilson Hope this message finds you well :smiley:

if the parameter is being treated as a single value, you might need to adjust the logic in your calculated field to ensure the in function correctly interprets the parameter as a list. My suggestion in this case is that you might need to split the string into a list if it’s being passed as a single string. Check the settings for the cohortIDs parameter in qs to ensure it is configured to accept multiple values.
For example, you might set up the calculated field like this:
in({patient_id}, split(${cohortIDs}, ","))
assuming cohortIDs is being passed as a single string and needs to be split into a list.
Adjust the logic based on how your parameter is actually being populated. If these steps do not resolve the issue, review how the parameter is being populated to ensure qs correctly interprets it as a multivalue parameter.

Please, tell me if it’s work for you!
I have never facing something like this for real, but I would like to understand how it could work :smiley:

Thanks for you reply @lary_andr. The solution does not work because cohortIDs contains the individual parameter values, not one long string. In addition, the split function requires a third parameter – position – and would only return one value from a csv string.

The calculated field works fine with the multiple value parameter when it is populated via the parameter drop down control like this:

But it fails when populating the multi-value parameter from a dynamic default like this:

So, the questions are:

  1. is it possible to populate a multiple value parameter with multiple values?
  2. is the correct input form to populate a multiple value string parameter with multiple values a comma separated list of those values i.e. (id1, id2, id3, id4, …)?
  3. why is the parameter control displaying all the dynamic default values (as shown in image at top), parameter itself doesn’t seem to contain them all? (super hard to see what values are in a multi value parameter.)
  4. why is the calculated field not acting on all those values when populated dynamically, but works as expected when populated from the parameter control?

Update: the failure to load multiple default values into the parameter is because of the space after the comma in the list of IDs (shown in image at top). So, “id1,id2,id3,id4” works. “id1, id2, id3, id4” only matches on id1 because subsequent ids in the list have a leading space: " id2".

So the original question is resolved as pilot error.