Welcome to the LimeSurvey Community Forum

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

assigning score to numerical input question

  • bodman
  • bodman's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 3 months ago #210545 by bodman
I'm new to limesurvey and on version 2.50+ Build 160804. I've read the manual and other similar posts about using expression manager to create an equation with if statements to assign custom values to a question answer. I've followed the format used in the manual but I can't get my equation to work. I have a single numerical input question (code:Q2) that asks to fill in a time value in minutes. I would like to score this value based on the criteria:

<= 15 = 0
16-30 = 1
31-60 = 2
>60 = 3

I made a hidden equation question following Q2 which is called Q2score. 

Q2score = {if(Q2.NAOK<=15,0,if(Q2.NAOK>=16&&<= 30,1,if(Q2.NAOK >= 31&&<= 60,2,if(Q2.NAOK > 60,3))))}

I've tried various formatting changes to this equation without any success. I am consistently getting an error that there is an extra comma found in my function or that my if statement is not valid based on what I have written. I must be missing something. Any help or direction would be appreciated.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #210547 by Joffm
Hi,
there are several small issues.
1. If you have an equation that is called "Q2Score" you must not assign the equation to "Q2Score". {if(...)} is sufficient.

2. Your AND operation is incorrect syntax. As we learned at school: A>12 AND A < 25
In your case:
Instead of Q2.NAOK>=16&&<= 30
Q2.NAOK>=16 && Q2.NAOK<= 30

3. The IF-statement is IF(condition,true,false).
So the red parts are not necessary because this is the FALSE part of the previous condition.
{if(Q2.NAOK<=15,0,if(Q2.NAOK>=16 && Q2.NAOK<= 30,1,if(Q2.NAOK >= 31 && Q2.NAOK<= 60,2,if(Q2.NAOK > 60,3))))}
Sufficient is:
{if(Q2.NAOK<=15,0,if(Q2.NAOK<= 30,1,if(Q2.NAOK<= 60,2,3)))}

Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu, bodman
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose