Welcome to the LimeSurvey Community Forum

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

Quotas on age range equation from age question

  • dgalloway
  • dgalloway's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 weeks ago #152314 by dgalloway
Hi,

I'm trying to do the following.

question 1: what is your age?
question code: SCREENC
type: numerical input

question 2: age ranges
code: SCREENC1
type: List question?

Trying to code question 1 into the following age ranges

1 Under 18
2 18 - 24
3 25 – 29
4 30 – 34
5 35 – 44
6 45 – 49
7 50 – 54
8 55+

I've put together this formula which i stuck in the question field on question 2

{SCREENC1=if(SCREENC.NAOK <= 18, "1", if(SCREENC.NAOK < 25, "2", if(SCREENC.NAOK < 29, "3" ,if(SCREENC.NAOK < 34, "4", if(SCREENC.NAOK < 44, "5", if(SCREENC.NAOK < 49, "6", if(SCREENC.NAOK < 54, "7" ,if(SCREENC.NAOK > 55, "8"))))))))}

I also need to set quotas on these age ranges so I don't think it can be an equation question. My formula doesn't seem to work, i get no answers in the 2nd question when i run it. What am I doing wrong? is there a better way to do this?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 weeks ago #152330 by tpartner
Replied by tpartner on topic Quotas on age range equation from age question
The formula needs to be in an equation question placed after SCREENC1. Also both SCREENC1 and the equation question need to be in a group following the SCREENC group because the equation is fired when the page loads.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • dgalloway
  • dgalloway's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 weeks ago #152333 by dgalloway
Replied by dgalloway on topic Quotas on age range equation from age question
I've tried setting it up that way with no luck getting it to work. See attached. I'm thinking I have an error in the equation but cant figure it out. I've been referencing this old forum question www.limesurvey.org/forum/design-issues/8...n-out-of-age-numeric

also if the age range question SCREENC1 and the equation question are hidden will they still run and can i create quotas on SCREENC1?

Thanks for your help!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 weeks ago #152338 by tpartner
Replied by tpartner on topic Quotas on age range equation from age question
Two problems...

1) If you want to dynamically manipulate questions, you cannot hide them with the advanced question setting - in that case, they are never rendered in the HTML so cannot be manipulated. If using version 2.5 or newer they can be hidden via CSS by adding a question class "hidden".

2) You forgot to add the final (empty) condition in your nested IF statements seen here with line-breaks inserted for clarity:
Code:
SCREENC1=if(SCREENC.NAOK <= 18, "1", 
  if(SCREENC.NAOK < 25, "2", 
    if(SCREENC.NAOK < 29, "3", 
    if(SCREENC.NAOK < 34, "4", 
      if(SCREENC.NAOK < 44, "5", 
      if(SCREENC.NAOK < 49, "6", 
        if(SCREENC.NAOK < 54, "7", 
        if(SCREENC.NAOK > 55, "8", 
          ""))))))))

Here's a copy of your survey with those items fixed:

File Attachment:

File Name: limesurvey...9392.lss
File Size:18 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose