- Posts: 22
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Define variables in question text and create new variables conditional on others
- Zirys
- Topic Author
- Offline
- Junior Member
Less
More
7 years 6 months ago #142169
by Zirys
Define variables in question text and create new variables conditional on others was created by Zirys
Dear users,
I want to show the following text to participants: "By paying x euros, you reduce y tons of CO2 emissions. This amounts to z % of your yearly CO2 emissions." Here, x is a random number, y is a function of x, z is a function of y.
Is it possible to implement in LimeSurvey?
I know how to create a random number ({rand(0,17)}), but I have not found a way to define this as a variable called, say, x, and then calculate (and show to participants) a new variable y based on x.
If someone could tell me whether this is possible in LimeSurvey, and if yes, could point me in a direction where I can find out how to do it, I would be very thankful.
Thanks in advance,
Zirys
I want to show the following text to participants: "By paying x euros, you reduce y tons of CO2 emissions. This amounts to z % of your yearly CO2 emissions." Here, x is a random number, y is a function of x, z is a function of y.
Is it possible to implement in LimeSurvey?
I know how to create a random number ({rand(0,17)}), but I have not found a way to define this as a variable called, say, x, and then calculate (and show to participants) a new variable y based on x.
If someone could tell me whether this is possible in LimeSurvey, and if yes, could point me in a direction where I can find out how to do it, I would be very thankful.
Thanks in advance,
Zirys
The topic has been locked.
- fvanderstarre
- Offline
- Elite Member
Less
More
- Posts: 176
- Thank you received: 36
7 years 6 months ago #142170
by fvanderstarre
Replied by fvanderstarre on topic Define variables in question text and create new variables conditional on others
You can use Expression Manager to define a question as type "equation". See the Expression manager section in the online Manual. You can also find many helpful sample surveys there!
The topic has been locked.
- Zirys
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 0
7 years 6 months ago - 7 years 6 months ago #142172
by Zirys
Replied by Zirys on topic Define variables in question text and create new variables conditional on others
I know this manual and I could not find an explanation of how to define a variable called x in the quesiton itself. It shows how to, e.g. make if statements with a variable that is already defined by the question code, but not how to define a variable in text.
It would be somthing like {x = rand(0,7)} to define the variable x.
Edit: Found out how to do it. Thanks for the hint.
It would be somthing like {x = rand(0,7)} to define the variable x.
Edit: Found out how to do it. Thanks for the hint.
Last edit: 7 years 6 months ago by Zirys.
The topic has been locked.
- BOBYJAMES
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 0
4 years 2 months ago #192582
by BOBYJAMES
hii ,
could you please tell how to do it ?
Replied by BOBYJAMES on topic Define variables in question text and create new variables conditional on others
Zirys wrote: I know this manual and I could not find an explanation of how to define a variable called x in the quesiton itself. It shows how to, e.g. make if statements with a variable that is already defined by the question code, but not how to define a variable in text.
It would be somthing like {x = rand(0,7)} to define the variable x.
Edit: Found out how to do it. Thanks for the hint.
hii ,
could you please tell how to do it ?
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12790
- Thank you received: 3940
4 years 2 months ago - 4 years 2 months ago #192584
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Define variables in question text and create new variables conditional on others
Hi,
best to study the EM sample surveys, especially the first "Relevance, Tailoring and Equations"
manual.limesurvey.org/Expression_Manager_sample_surveys
And read the manual about question type "equation"
manual.limesurvey.org/Question_type_-_Equation
Joffm
best to study the EM sample surveys, especially the first "Relevance, Tailoring and Equations"
manual.limesurvey.org/Expression_Manager_sample_surveys
And read the manual about question type "equation"
manual.limesurvey.org/Question_type_-_Equation
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 2 months ago by Joffm.
The topic has been locked.
- BOBYJAMES
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 0
4 years 2 months ago #192589
by BOBYJAMES
Replied by BOBYJAMES on topic Define variables in question text and create new variables conditional on others
thanks for your reply..
but i can't find how to define a user defined variable..
can you please tell how we can define a variable and store some value to that variable... lets take it as x.. ?
but i can't find how to define a user defined variable..
can you please tell how we can define a variable and store some value to that variable... lets take it as x.. ?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
4 years 2 months ago #192590
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Define variables in question text and create new variables conditional on others
Create an equation type question and load it with a hard value or via Expression Manager. This becomes your variable.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- BOBYJAMES
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 0
4 years 2 months ago #192595
by BOBYJAMES
Replied by BOBYJAMES on topic Define variables in question text and create new variables conditional on others
I try to do this... but didn't work as we expected..
can you please show an example of how to define a variable x in an equation question?
can you please show an example of how to define a variable x in an equation question?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
4 years 2 months ago #192599
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Define variables in question text and create new variables conditional on others
I'm sorry, I don't know what more to add or how to explain it more simply.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12790
- Thank you received: 3940
4 years 2 months ago #192602
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Define variables in question text and create new variables conditional on others
Did you study the survey I mentioned?
You also find it in the Demo installation here ("Tayloring Examples")
There you find four "user defined variables":
weightkg, heightm, BMI and weightstatus.
And fvanderstarre and tpartner explained it already.
Joffm
You also find it in the Demo installation here ("Tayloring Examples")
There you find four "user defined variables":
weightkg, heightm, BMI and weightstatus.
And fvanderstarre and tpartner explained it already.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu
The topic has been locked.