How do you create multi-select controls?

sfinnegan
sfinnegan Member
edited March 2023 in Variables

As far as I know Variables can only have Controls that are single selection, is there a way to create mult-select variables and by extension multi-select controls?


Tagged:

Answers

  • Right now no, this isn't possible because it can't store multiple values into a single variable. You can post this idea to the idea exchange to see if they can add it but might be difficult from a technical limitation standpoint.

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • @sfinnegan You wouldn't be able to do it because if multiple inputs were selected, how would your beast mode/equation know what the result should be? Ex: Using numbers as an example, if you had to evaluate if x=1, and you set x equal to 1 and 2 at the same time, your evaluation wouldn't know if the result is true or false. What's your end goal, and maybe there's a workaround?

    **Was this post helpful? Click Agree or Like below**

    **Did this solve your problem? Accept it as a solution!**

  • Jbrorby
    Jbrorby Contributor

    Piggybacking off sginnegan, my situation is that we are a blood center and when someone donates, it creates a donation id. Some of these donations end with deferral codes. We have over 160 deferral codes, but for the sake of this example, lets say we have 5: A, B, C, D, E. I have a user who wants to be able to dynamically select 1 or more groups of deferral codes with the denominator (total donations with all deferral codes) remains constant. I thought variables might be a solution as I could set up all the deferral codes in a variable and make a beastmode count(distinct case when deferral code = variable then donation id end) / count(distinct case when deferral code is not null then donation id end). And this does work, but the user would want to be able to select more than 1 deferral code for the numerator.

    One thing I tried was, in the ETL, getting the total count of deferrals per day and just joining it to every collection date hoping I could use a FIXED By as the denominator, but then realized if a deferral code did not happen on that day and was selected in the filter, then I would lose the denominator for that day. So this route would probably require some sort of carteisian join to get the denominator on every deferral code and that code on every day and then append it, but I don't know if i want to add that much data to the dataset

  • This isn't particularly scalable, but you could create duplicate variables and use "or" conditions in your case statement. On the dashboard, you could create a control for each copy of the variable. If you want them to be able to select 5 different deferral codes, create 5 copies of the variable.

    Example case statement:

    count(distinct case when (deferral code = variable1 ) or (deferral code = variable 2) or …() then donation id end) / count(distinct case when deferral code is not null then donation id end)

    This wouldn't scale to 160 codes, though. Your ETL approach is logically sound and more scaleable, and you're right that it would require a full join with the calendar dataset to insure every code is matched to every day. 160 codes x 365 days is about 60k rows per year. I'm not sure what your space limitations are, but that's not unreasonably huge.

    Please 💡/💖/👍/😊 this post if you read it and found it helpful.

    Please accept the answer if it solved your problem.