How to make reference to the highest value in a multi-select question

Hi SuSo team,

I would like to know how to make reference to the highest value in a multi-select question based on the answers selected for that question.

Many Thanks,

The syntax ultimately depends on which ‘type’ of multi-select question you want to work with, see Questions - Data Types.

Assuming a ‘regular’ multi-select not linked, called Q1, you could simply use:

Q1.Max()

Out of curiosity: For which use case do you need this value? Can you elaborate?

1 Like

Hi @peter_brueck, Thanks for the help!

more context; I have a regular multi-select question (Q1) which asks to select the months in which the business operated in the past 12 months. And the income and expenditures needed to be recorded for the LAST month of operation for that particular business.

Therefore, to pipe the last month of business operation into the question text, I needed to know how to make a reference to the highest value in that Multi-select question.

Q1.Max() shows the highest value in Q1.

I have one more question. In order to show the associated string for that value, what syntax can I use?

This approach has one subtle problem:

  1. After your interviewer responds MARCH, APRIL, MAY to Q1, the Q2 will sound like “What was your income in MAY?
  2. Suppose you get the answer 200 as the answer to it.
  3. Now in the course of the conversation your interviewer realizes that the business was still operating in JUNE, goes and adds this to Q1.
  4. This change transforms the question text in Q2 to “What was your income in JUNE?”. But the answer remains 200. And the question remains answered.

Do you think this may be an issue for your survey? Do you have a way to deal with it already?

Hi @sergiy, Thanks for pointing this out.

I’m not sure if it would be an issue!

Example: If the question is phrased as “What was your income in the last month of operation”. (Q1.Max()) <== The question phrasing doesn’t change but the reference month within the brackets does.

I don’t think the problem would be solved even if we do not give a reference. If the answer to Q1 changes halfway through the interview, either way the answer recorded first remains saved unless and until the interviewer himself changes it. Please correct me if I am wrong.

If you’ve any other solutions to tackle this issue, please guide me through it.

Many Thanks,

Regarding the follow-up question:

Assuming that multi-select question Q1 stores the month “Jan” - “Dec” with categorical values 1 - 12, you could create a variable of type string. Within the expresison of that variable you can create an array with string items - that needs to follow the same sequence of categorical values/titles in Q1 - and then return the value (the month) of the array based on its index. The index is based on answer to Q1:

new[]{
    "January",
    "February",
    ...
    "November",
    "December"
}[(int)Q1.Max()-1]
  • It’s error prone. If the order of months within the array does not follow Q1 coding (1 = January, 4= April etc.), you will get a wrong result
  • For multi-lingual surveys you will only be able to display the month in the language you included in this variable.
  • Attention: You state “in the past 12 months”. If you field this survey in April, the LAST month of operation is not the maximal value of Q1 (with December=12) but would be March/April. So you’d need to adjust your categorical values and this string variable accordingly.
1 Like

I agree that this is an issue, but isn’t this a general issue when you do text substitution in a question text, which pipes answers to a previous question?

Actually never thought too much about this, any users experience on how to deal with this are appreciated.

This was very helpful.

Thanks a lot! @peter_brueck