Welcome to the LimeSurvey Community Forum

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

Number between previous question

  • brais24
  • brais24's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 11 months ago #216505 by brais24
Number between previous question was created by brais24
Hi folks, I need to do the following, I have 2 questions, the first question is a drop down list that asks how many workers do you have (None, from 1 to 2, from 3 to 9, from 10 to 49, from 50 to 249 and more than 250 ).

The second question is a text matrix but it uses numbers, in which you have to put how many men and women you have hired and in what positions.

What I need to do is that if you choose from 3 to 9, for example, I only let you enter in the second question, in the total sum, between 3 and 9.

I am attaching the lss with the two questions, I have tried to do it on my own, but at most I have managed to set the same number as the limit that I enter in question 2, I would greatly appreciate the help.

Thank you.

My LS version is  2.72.3+171020

File Attachment:

File Name: limesurvey...2893.lss
File Size:36 KB
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 11 months ago #216506 by Joffm
Replied by Joffm on topic Number between previous question
Hi,
this "3 to 9" is only a text.

So try to validate the number like

if(Q1==2,sum(self.NAOK) ge 1 and sum(self.NAOK) le 2,if(Q1==3,sum(self.NAOK) ge 3 and sum(self.NAOK) le 9,if(Q1==4,sum(self.NAOK) ge 10 and sum(self.NAOK) le 49,if(Q1==5,sum(self.NAOK) ge 50 and sum(self.NAOK) le 249,sum(self.NAOK) ge 250))))}
 with codes of Q1
1: 0
2: 1-2
3: 3-9
4: 10-49
5: 50-249
6: >249
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • brais24
  • brais24's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 11 months ago #216524 by brais24
Replied by brais24 on topic Number between previous question
Yes, the P1 is a dropdown list, so, if I select the option from 3 to 9 workers, the option 2 just have to let me put a total between 3 and 9.

I try to use that code but dont work, the first question is P1 with items called (A1,A2,A3...), I try to put this code on ecuation validation question of P2 question, but dont do nothing, where I fail?

I dont understand the "ge" and "le" on your code.

if(P1==A2,sum(self.NAOK) ge 1 and sum(self.NAOK) le 2,if(P1==A3,sum(self.NAOK) ge 3 and sum(self.NAOK) le 9,if(P1==A4,sum(self.NAOK) ge 10 and sum(self.NAOK) le 49,if(P1==A5,sum(self.NAOK) ge 50 and sum(self.NAOK) le 249,sum(self.NAOK) ge 250))))}
The topic has been locked.
  • brais24
  • brais24's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 11 months ago #216525 by brais24
Replied by brais24 on topic Number between previous question
And should show an error message when you put another number, like, please, insert a total betweeen X and Y.

Thank you
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 11 months ago #216543 by Joffm
Replied by Joffm on topic Number between previous question
1. As usual
Read the manual
[url] manual.limesurvey.org/ExpressionScript_-_Presentation#Syntax [/url]

2. Error message? Of course. This you do in the validation tip.
This you do in a similar way, like:
{if(Q1==2 AND (sum(self.NAOK) lt 1 OR sum(self.NAOK) gt 2,"Please, insert a total between 1 and 2",if(Q1==3 AND ... 

By the way: Your codes "A1", "A2",... are text, not numbers. So you have to compare texts (quotes)
Q1=="A2"

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • brais24
  • brais24's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 11 months ago #216574 by brais24
Replied by brais24 on topic Number between previous question
Ok thx for the help, finally I do thisI rename P1 as Q1 and on P2 put this, with this I have the 2 first validation,jus repeat for the others.

Ecuation validation question of P2
if(Q1== "A2" ,sum(self.NAOK) >= 1 AND sum(self.NAOK) <=2 ,if(Q1== "A3" ,sum(self.NAOK) >= 3 AND sum(self.NAOK) <=9,sum(self.NAOK) == 2))

Ecuation validation help of P2
{if(Q1 == "A2", "La suma debe estar entre 1 y 2","")}
{if(Q1 == "A3", "La suma debe estar entre 3 y 9","")}
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose