Welcome to the LimeSurvey Community Forum

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

Group the answers from a previous question to be displayed to participants.

  • willykriswardhana
  • willykriswardhana's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 months 5 days ago #250608 by willykriswardhana
Your LimeSurvey version: 5.6.38
==================
Hi everyone,

I'm a student and now going to run a survey using LimeSurvey. 

I want to categorize/group the answers of a previous question to be displayed to the participants. 

For example:

Case 1
Residence: Where do you live?
Answer: A01 "Vienna", A02 "Budapest", A03 "New York", A04 "Jakarta"

Continent: *displayed to participants* (in this case, I use "text display" question type)
"Europe", "America", "Asia"

I want to group the "Residence" answers into "Continent". I have tried like this in the Condition box (in the "Continent" question):

if(Residence.NAOK="A01","Europe",if(Residence.NAOK="A02","Europe",if(Residence.NAOK="A03","America","Asia")))


Case 2
Age: How old are you?
Answer: Numerical input

AgeGroup: *displayed to participants* (in this case, I use "text display" question type)
"<25", "25-39", "40-54", "55-69", ">69"

I want to group the "Age" answers into "AgeGroup". I have tried like this in the Condition box (in the "AgeGroup" question):

if(Age.NAOK < 25, "1", if(Age.NAOK <= 39, "2", if(Age.NAOK <=54 , "3", if(Age.NAOK <= 69, "4", "5"))))

but nothing happens. 

Your help is highly appreciated. 

Thank you...
 
Attachments:

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 months 5 days ago #250609 by Joffm
Hi,
first I recommend to read the manual about ExpressionScript.
[url] manual.limesurvey.org/ExpressionScript_E...Quick_start_guide/en [/url]
E.g. the BMI example.

And you also may download and study the sample surveys
[url] manual.limesurvey.org/ExpressionScript_sample_surveys/en [/url]

In this "Condition" box you enter a logical term which either displays the question or not.
If it is TRUE the question is displayed, if FALSE it is not displayed.

But you want to do something quite different.
You only want to display something in a question of type "text display".
So you enter your function into the question text.
And DON'T FORGET to surround with curly brackets.

And you'd better use numerical codes.
Then you may use:
{if(Residence.NAOK<3,"Europe",if(Residence.NAOK<4,"America","Asia")))}



And the age group?
Now you only display  "1", "2", "3",... What for?
You#d better store the age group in a (hidden) question of type "list(radio)"
Here you have to assign the result to this question of type in a question of type "equation"
Let's call the questions "AgeGroup" and "eqAge" (eq=equation)
Well, AgeGroup with the answer options
1: younger than 25 years
2: 25-39 years old
...
in "eqAge" you assign the values according to your shown formula.
{AgeGroup=if(Age.NAOK < 25, 1, if(Age.NAOK <= 39, 2, if(Age.NAOK <=54 , 3, if(Age.NAOK <= 69, 4, 5))))}

Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: willykriswardhana

Please Log in to join the conversation.

  • willykriswardhana
  • willykriswardhana's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 months 4 days ago #250628 by willykriswardhana
It works.

Thank you so much!

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose