Survey Solutions

Support portal and knowledge base

Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Minimum?

Benjamin Feb 16, 2017 11:04PM EST

Dear support,

For the survey instrument I am designing, I need to select the minimum value in two different situation:
- from a categorical: multi-select variable.
e.g. Where did you seek treatment from: answers are (2) Public hospital, (5) Private clinic and (9) Pharmacy. For following questions, I will ask only about the answer with lowest code, here Public hospital.

- from a roster.
e.g. my education roster has two cases corresponding to two kids: Kid 1 has achieved Grade 5 and Kid 2 has achieved 3. I want to ask questions (out of the roster) about the kid with lowest level of education.

Any idea on how I could achieve these? I have seen the function MIN on C# but not sure on how to use it, and on whether it works for a multi-select and/or within a roster.
Thanks a lot!
Best,

Benjamin.

Up 0 rated Down
Sergiy Radyakin Feb 17, 2017 03:56AM EST Survey Solutions Agent

Benjamin, you are absolutely right about the use of the Min() function.

For the first question – the expression mcq.Yes.Min() will give you the value of the lowest selected option (2 in your example) regardless of the order of options.

For the second question, please describe how you want to break the ties (example: of 10 kids, the lowest grade was achieved by 3).

Best, Sergiy

Up 0 rated Down
Benjamin Feb 20, 2017 08:57PM EST
Hi Sergiy,

Thanks for your answer. Should I include mcq.Yes.Min() into a new variable? My multi-select question is named Q3_5, so the syntax would be Q3_5.mcq.Yes.Min()? I actually found another way of doing this: I created a sub-roster based on the choices selected at Q3_5, but restricted it to @rowcode==0. This works.

For the second question, the idea is to select the kid with the lowest level of education for the following questions. In my system, the education roster is fed by my initial household members roster. Only kids aged 6-16 years old are selected. One of the question, named Q4_7, asks about the kid's level of education. Then, out of this roster, I want to ask more about one kid only, the one with the lowest level of education. The system thus needs to identify the minimum value for Q4_7 within the roster, and select the concerned kid only. Not sure if this is clear...

Sorry for the long message. Cheers,

Benjamin.
Up 0 rated Down
Sergiy Radyakin Feb 21, 2017 03:19AM EST Survey Solutions Agent

Benjamin,

I used mcq to denote Multiple Choice Question the name of which was not specified in your original query. You need to write the actual variable name (Q3_5) instead of “mcq”.

The method you ended up using works, but may create unnecessary complexity as it creates a new level of data. In many cases this is not required. The rule of thumb is that the roster’s purpose is to replicate questions for N items. If you know there will always be N=1, there is no need for a roster. You don’t have to assign the expression to a variable, but it may improve readability of some expressions.

For the second question you wrote “ask more about one kid only, the one with the lowest level of education” but you still haven’t specified what do you want to do in case children Arnold, Berta and Charlie each have grade 3 completed. You specified that you want to talk to 1 kid only. Which one? Youngest? oldest? listed first? random? alphabetical?

Best, Sergiy

Up 0 rated Down
Benjamin Feb 21, 2017 07:56PM EST
Sergiy,

I get that my method is clumsy (and I try to avoid rosters when I don't actually need them)... But I just don't how to use the Min function yet, so I tried to imagine another way of doing this. So do I need to write "Q3_5.Yes.Min()"? I tried to write this command as an enabling condition or as a variable, but it both cases it doesn't compile. Is there any argument I should specify between the brackets?

For the second question I get your point, sorry: once finding out the kid(s) with the lowest grade, I would select the youngest one.

Thanks again. Best,

Benjamin.
Up 0 rated Down
Sergiy Radyakin Feb 23, 2017 08:50AM EST Survey Solutions Agent

Benjamin,

the answer to #1 is here:
http://support.mysurvey.solutions/customer/portal/articles/2751433

the answer to #2 is here:
http://support.mysurvey.solutions/customer/en/portal/articles/2751355

Best, Sergiy

Up 0 rated Down
Benjamin Feb 23, 2017 10:31PM EST
Hi Sergiy,

Awesome! Solution 1 works great (without the "Yes" as I usually do not use the Yes/No recording function for multiple answers) and indeed permitted to avoid the 1-line roster. Just one question for curiosity: for V2 (in your example, where you record the string name for the minimum value), why the "V1-1"?

I'm still struggling with the method proposed for question 2, and I think that this could be related to the fact that my name, age and grade variables aren't in the same section/roster: name is recorded as a list ("FULLNAME") and feeds the household members roster ("HHROSTER") where age is asked about ("Q1_2"). A later section contains the education roster ("EDUROSTER", asking for all members 6-16 years old) and the grade question ("Q4_7"). I tried to compute the string variable "KIDNAME" following your instructions, as follows:

EDUROSTER.Where(
p=>IsAnswered(p.FULLNAME)
&& IsAnswered(p.Q1_2)
&& IsAnswered(p.Q4_7)
).Where(
p=>p.Q1_2.InRange(6,16)
&& p.Q4_7.InRange(1,98)
).OrderBy(p=>p.Q4_7).ThenBy(p=>p.Q1_2).First().FULLNAME

Sorry for asking so many questions and thanks for the great help. I plan to start studying C# to be more at ease with Survey Solutions and try to ask you less programming related questions.
Best,

Benjamin.
Up 0 rated Down
Benjamin Feb 23, 2017 10:37PM EST
This is probably why you wrote that it is more convenient if all questions are in the same sub-section...
Up 0 rated Down
Benjamin Feb 23, 2017 11:30PM EST
Ok, my workmate Lachlan gave me a hand on that: because we feed the HHROSTER from a list of names, the syntax is slightly different (than if we first ask how many people in the HH and then ask the name of each of them). Thus I wrote:

HHROSTER.Where(
p=> IsAnswered(p.Q1_2)
&& IsAnswered(p.Q4_7)
).Where(
p=>p.Q1_2.InRange(6,16)
&& p.Q4_7.InRange(1,98)
).OrderBy(p=>p.Q4_7).ThenBy(p=>p.Q1_2).First().@rowname

But @rowname does not work and sends back "obsolete, don't use it". Any alternative to @rowname that would work then? I promise this is my last message of the day, sorry for this.
Best,

Benjamin.
Up 0 rated Down
Sergiy Radyakin Feb 26, 2017 08:37AM EST Survey Solutions Agent

Dear Benjamin,

what you can do is take @rowcode instead of the @rowname. This will be the code of the person in question. Call this variable PERSCODE.
then create another variable PERSNAME retrieving the person’s name by code from the original household members list question. The list question is a TUPLE structure in C#, see the link in the data types page:
http://support.mysurvey.solutions/customer/en/portal/articles/2531232

Then you can substitute PERSNAME in the question text.

Best, Sergiy

Up 0 rated Down
Benjamin Feb 27, 2017 01:19AM EST
Dear Sergiy,

Ok well it still doesn't work: @rowcode does apparently not work as the roster is linked to the list question. But I found another way, still using the script you gave me: instead of selecting the @rowname, I select the @rowindex and I used the clumsy one-line roster technique I told you about previously (roster questions only appear for the kid selected through the above script, lowest grade and lowest age). That's ugly I agree but that works. I'll study further how to make it nicer later, as the team needs to go on the field next week!

Thanks a lot for your precious help. Now I know how to get the minimum from roster and mcq. Much appreciated.

Best regards,

Benjamin.

This question has received the maximum number of answers.

support@mysurvey.solutions
http://assets3.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete