Calculate a Select Multiple based on Previous Question

624
3
09-28-2022 05:59 AM
RobertAnderson3
MVP Regular Contributor

There may be forum posts for this, I'm still digging but wanted to put this out there.

I'm looking at if it's possible to use a calculation on a select_multiple to select a set of answers based on a previous question's answer.

In a nutshell, our user has a list of assets to handle on a given day, and that list is the same week after week (every Monday it's the same) but there is potential for change (they couldn't finish them all, an extra was done) so I want them to be able to change it.

But since it's a list of 50 or so, I'd like them to be able to pick which day of the week and have the select_multiple default to that day's list. The way I have the choice list set up it would be nice if it can use the choice label in the calculation, but if that's too much extra work I can clean up the data later.

Has anyone set up something similar to this? I'm assuming I'll need a regex of some kind.

0 Kudos
3 Replies
DougBrowning
MVP Esteemed Contributor

I think I get what you are asking.  You can default a select multiple by giving it a list like "one,two,three" - note you need the quotes there.  You could do this as a big if statement like if(monday, mondaylist, if tuesday, tuesday list) etc.

You could also maybe use pulldata to grab the list from a csv.  Like pulldata(tasklist, day, etc) and it returns a list of values.

You cannot use the label for the calc though it has to be the name.  If you can just make the name and label the same.  The user should not even see the calc so not sure why it would matter.

Hope that helps

0 Kudos
RobertAnderson3
MVP Regular Contributor

Thanks Doug! 

The if statement would get massive, I was hoping maybe I could work a regex into it to save that?

Currently the list is stored is stored as a csv so that sounds promising, can you tell it to select certain options using this? I'm familiar with setting up a choice filter in this way, but I want them to still be able to see the rest of the list so they have the option to select additional ones if needed.

Yeah I can drop the label part. The name is an Asset ID that I'd be passing to another system, so having the day on it would mess that up, but I can clean it up later.

0 Kudos
LaurenceTait
Occasional Contributor II

If I'm understanding you correctly:

You have a list of tasks.

Each day is associated with a pre-determined list of tasks that is a subset of the full list.

You want your operators to select the day, and then you want the survey to generate the list of tasks for that day so they know what they are expected to do.

And you also want that list of the day's tasks to appear as the default answer for a select_multiple question, so your users can add or subtract tasks from that list depending on whether they complete more or less tasks than expected.

So your final result should look something like this:

LaurenceTait_2-1664413760225.png

 

LaurenceTait_1-1664413687508.png

 

Is that correct? 

If so this can be relatively easily achieved using paired CSVs and the 'pulldata' and 'select_multiple_from_file' options.