Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

only show next question if Sum of Q3, 4 and 5 equals the number entered in Q2

More
3 weeks 2 days ago #273689 by vthiel
Please help us help you and fill where relevant:
Your LimeSurvey version: Online Version, Free
Own server or LimeSurvey hosting:
Survey theme/template:
==================
Hi, 
so we're tryalling lime survey to do an annual monitoring for about 15 orgs. It involves breaking down a total sum of incidents into different categories. Lets say they collect flowers. they are either red, blue or yellow, the answers are fixed. 
For example, in total, an organisation collected 50 flowers. 20 were red, 20 were blue, and 10 were yellow. After this section, they are asked about further markers, like size, petal shape and so on. Often, people get confused and the subcategories do not add up to the total number. I therefore want to build in either a warning/error message that tells them they got mixed up, and make sure they can only progress to the next set of questions once the numbers are added up.

Q2: How many flowers did you collect. - A 50
Q3 How many of these were red - 18
Q4: How many of these were blue - 17
Q5 How many of these were yellow- 10

ERROR: sum of flowers do not add up to total sum of flowers. 

Hope this makes sense.
What syntax should I enter in the expression builder?
Bear in mind we only use the web version, we're too small to host a server and only run the survey once a year. 
Many thanks in advance! 
 

Please Log in to join the conversation.

More
3 weeks 2 days ago #273691 by tpartner

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
3 weeks 9 hours ago #273699 by paul.borsdorf
Hi, you can use expressionscript to sum it up or you can use the question type "multipe numerical input" (in section "mask questions"): In the settings of this questiontype you can define "Equals sum value" (in section "Input").
Does that help you?

Brauchen Sie Unterstützung bei der Erstellung und Auswertung von Umfragen mit LimeSurvey?
Mein Angebot als autorisierter LimeSurvey-Partner finden Sie auf meiner Website www.paulborsdorf.de

Please Log in to join the conversation.

More
3 weeks 4 hours ago - 3 weeks 4 hours ago #273704 by Joffm
The usual way is what Paul proposed, the multiple numerical input.

Now the promised two examples:
1. One question to collect the total (Q1a), one question to collect the colors.(Q1b)
In "Input / Max.Sum. Value & Min. Sum Value" you enter the reference to the first question, just Q1a_1
This is better than to enter "Equal Sum Value"; it avoids the "remaining" line
Remark
: To have a better look&feel question Q1a also is of type "multiple numerical" with only one subquestion.
 
Disadvantages:
  • You already get an error before you filled all subquestions.
  • The "total" is not aligned properly (except "fruity twentythree")

2. Only one question of type "multiple short text" (this "total" row is not displayed)
Here we ask all four sub questions in one question.
And the validation is "The sum of the rest is equal to the first cell"
So this we enter as question validation equation Q2_1==sum(Q2_2,Q2_3,Q2_4)
And the error message we enter in the question text as an IF-statement, like
<p style="color:red;font-weight:bold">{if(count(self)==4 and Q2_1!=sum(Q2_2,Q2_3,Q2_4),'sum of flowers do not add up to total sum of flowers','')}</p>
 

 

File Attachment:

File Name: limesurvey...1921.lss
File Size:55.07 KB

Joffm

P.S.
You can improve the error message a bit by inserting the actual values, like
<p style="color:red;font-weight:bold">{if(count(self)==4 and Q2_1!=sum(Q2_2,Q2_3,Q2_4),'sum of flowers ('+sum(Q2_2,Q2_3,Q2_4)+') do not add up to total sum of flowers ('+Q2_1+')','')}</p>
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 weeks 4 hours ago by Joffm.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose