- Posts: 19
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Randomnumber based variables
- tischer_s
- Topic Author
- Offline
- New Member
Less
More
9 years 10 months ago #110450
by tischer_s
Randomnumber based variables was created by tischer_s
Hi,
In my survey I have 16 treatments which are randomized via a rand(1;16) function.
Now I want to implement two hidden questions containing of the independant changed variables which are filled with numbers based on the random number.
In each treatment either the storage and/or the price is changed.
Here some examples:
Rand 1 -> storage: 2GB ; price: 0€
Rand 2 -> storage: 2GB ; price: 9,99€
Rand 3 -> storage: 2GB ; price: 19,99€
Now I want the variable price and storage and they should be hidden for the users but fill with numbers based on the values shown.
Rand 1 -> storage: 2 ; price: 0
Rand 2 -> storage: 2 ; price: 9,99
Rand 3 -> storage: 2 ; price: 19,99
Something like:
If randnumber=2, storag=2; price=9,99
This is no function but should cover what I want.
Can anoyone please help me with a function for this?
Best
Sebastian Tischer
In my survey I have 16 treatments which are randomized via a rand(1;16) function.
Now I want to implement two hidden questions containing of the independant changed variables which are filled with numbers based on the random number.
In each treatment either the storage and/or the price is changed.
Here some examples:
Rand 1 -> storage: 2GB ; price: 0€
Rand 2 -> storage: 2GB ; price: 9,99€
Rand 3 -> storage: 2GB ; price: 19,99€
Now I want the variable price and storage and they should be hidden for the users but fill with numbers based on the values shown.
Rand 1 -> storage: 2 ; price: 0
Rand 2 -> storage: 2 ; price: 9,99
Rand 3 -> storage: 2 ; price: 19,99
Something like:
If randnumber=2, storag=2; price=9,99
This is no function but should cover what I want.
Can anoyone please help me with a function for this?
Best
Sebastian Tischer
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13668
- Thank you received: 2496
9 years 10 months ago - 9 years 10 months ago #110467
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Randomnumber based variables
Hi,
Don't really understand your need here.
But you can use Equation question type and EM.
1st question RANDOM : {rand(1,3)}
Equation hidden question : {if(RANDOM== "1" or RANDOM== "2" or RANDOM== "3",2,"")}
etc ....
You can use one Equation question type and Assign a answer:
{ANDWER=if(RANDOM== "1" or RANDOM== "2" or RANDOM== "3",2,"")}
See : manual.limesurvey.org/Expression_Manager
Don't really understand your need here.
But you can use Equation question type and EM.
1st question RANDOM : {rand(1,3)}
Equation hidden question : {if(RANDOM== "1" or RANDOM== "2" or RANDOM== "3",2,"")}
etc ....
You can use one Equation question type and Assign a answer:
{ANDWER=if(RANDOM== "1" or RANDOM== "2" or RANDOM== "3",2,"")}
See : manual.limesurvey.org/Expression_Manager
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 9 years 10 months ago by DenisChenu. Reason: manual link
The topic has been locked.
- tischer_s
- Topic Author
- Offline
- New Member
Less
More
- Posts: 19
- Thank you received: 0
9 years 10 months ago #110468
by tischer_s
Replied by tischer_s on topic Randomnumber based variables
Hi DenisChenu,
I am sorry for not writing it more clearly.
I need to give an value to a variable based on the random number.
My questionnaire starts with a randomnumber generator (rand(1,16)). Then I have treatments which I only show when each randomized number is shown.
randnum 1 -> Treatment 1
randnum 2 -> Treatment 2
...
Each Treatment varies in price and storage. For a better export I want to have two new hidden "questions" where the number and storage of the treatment is in.
Like:
randnum 1 -> price: 0 storage: 2
randnum 2 -> price: 9,99 storage: 2
randnum 3 -> price: 19,99 storage: 2
Your expression is a good start unfortunately I don't know how to set a value as an answer...
{if(RANDOM== "1") then price=="0" and storage=="2"}
Is anything like this even possible?
Best and thank you very much
Sebastian
I am sorry for not writing it more clearly.
I need to give an value to a variable based on the random number.
My questionnaire starts with a randomnumber generator (rand(1,16)). Then I have treatments which I only show when each randomized number is shown.
randnum 1 -> Treatment 1
randnum 2 -> Treatment 2
...
Each Treatment varies in price and storage. For a better export I want to have two new hidden "questions" where the number and storage of the treatment is in.
Like:
randnum 1 -> price: 0 storage: 2
randnum 2 -> price: 9,99 storage: 2
randnum 3 -> price: 19,99 storage: 2
Your expression is a good start unfortunately I don't know how to set a value as an answer...
{if(RANDOM== "1") then price=="0" and storage=="2"}
Is anything like this even possible?
Best and thank you very much
Sebastian
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13668
- Thank you received: 2496
9 years 10 months ago #110474
by DenisChenu
et ...
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Randomnumber based variables
tischer_s wrote: Your expression is a good start unfortunately I don't know how to set a value as an answer...
{if(RANDOM== "1") then price=="0" and storage=="2"}
Is anything like this even possible?
Code:
{price=if(RANDOM== "1",0,1)} {storage=if(RANDOM== "1",2,1)}
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- tischer_s
- Topic Author
- Offline
- New Member
Less
More
- Posts: 19
- Thank you received: 0
9 years 10 months ago #110478
by tischer_s
Replied by tischer_s on topic Randomnumber based variables
Hi DenisChenu,
Thanks a lot for your great help This is exactly what I was searching for!
Only three questions:
1. how can I combine multiple statements like random=="1" and random=="2" etc?
2. what is the second number in the "1",0,1 statement?
3. how can I enter the number 9,99? Do I need a fullstop as separation?
Is this right?
Thanks a lot for your great help This is exactly what I was searching for!
Only three questions:
1. how can I combine multiple statements like random=="1" and random=="2" etc?
2. what is the second number in the "1",0,1 statement?
3. how can I enter the number 9,99? Do I need a fullstop as separation?
Is this right?
Code:
{price=if(RANDOM== "1",0,1),if(RANDOM=="2",9,99),if(RANDOM=="3",19,99} {storage=if(RANDOM== "1",2,1)}
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13668
- Thank you received: 2496
9 years 10 months ago #110479
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Randomnumber based variables
Please : read the doc ..
manual.limesurvey.org/Expression_Manager
manual.limesurvey.org/Expression_Manager
Code:
{price=if(RANDOM== "1",0, if(RANDOM=="2",9, if(RANDOM=="3",19,99) ) )}
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: tischer_s
The topic has been locked.
- tischer_s
- Topic Author
- Offline
- New Member
Less
More
- Posts: 19
- Thank you received: 0
9 years 10 months ago - 9 years 10 months ago #110483
by tischer_s
Replied by tischer_s on topic Randomnumber based variables
Hi again,
I am so sorry for disturbing you. Unfortunately I am not that technical knowledged thats why I am running into some trouble
I entered the following code now into my question field named "price":
Unfortunately it tells me that there is an extra comma in the function? Am I doing something wrong?
Thank you very much
Best
Sebastian
I am so sorry for disturbing you. Unfortunately I am not that technical knowledged thats why I am running into some trouble
I entered the following code now into my question field named "price":
Code:
{price=if(randnumber== "1","0", if(randnumber=="2","9,99", if(randnumber=="3","19,99", if(randnumber=="4","49,99", if(randnumber=="5","0", if(randnumber=="6","9,99", if(randnumber=="7","19,99", if(randnumber=="8","49,99", if(randnumber=="9","0", if(randnumber=="10","9,99", if(randnumber=="11","19,99", if(randnumber=="12","49,99", if(randnumber=="13","0", if(randnumber=="14","9,99", if(randnumber=="15","19,99", if(randnumber=="16","49,99"))))))))))))))))}
Unfortunately it tells me that there is an extra comma in the function? Am I doing something wrong?
Thank you very much
Best
Sebastian
Attachments:
Last edit: 9 years 10 months ago by tischer_s. Reason: Small typo
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13668
- Thank you received: 2496
9 years 10 months ago #110491
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Randomnumber based variables
Because you allways need a 'if false' value.
Code:
{price=if(randnumber== "1","0", if(randnumber=="2","9,99", if(randnumber=="3","19,99", if(randnumber=="4","49,99", if(randnumber=="5","0", if(randnumber=="6","9,99", if(randnumber=="7","19,99", if(randnumber=="8","49,99", if(randnumber=="9","0", if(randnumber=="10","9,99", if(randnumber=="11","19,99", if(randnumber=="12","49,99", if(randnumber=="13","0", if(randnumber=="14","9,99", if(randnumber=="15","19,99", if(randnumber=="16","49,99",""))))))))))))))))}
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: tischer_s
The topic has been locked.
- tischer_s
- Topic Author
- Offline
- New Member
Less
More
- Posts: 19
- Thank you received: 0
9 years 10 months ago #110492
by tischer_s
Replied by tischer_s on topic Randomnumber based variables
Hi again,
thank you sooo very much for your great help! Now the equation is working without errors.
Unfortunately it is not giving me an answer based on the expression?
In my answer panel I get this output not any of the numbers we assigned to the randomnumber
May you please help me one more time?
Best
Sebastian
thank you sooo very much for your great help! Now the equation is working without errors.
Unfortunately it is not giving me an answer based on the expression?
In my answer panel I get this output not any of the numbers we assigned to the randomnumber
May you please help me one more time?
Best
Sebastian
Attachments:
The topic has been locked.
- tischer_s
- Topic Author
- Offline
- New Member
Less
More
- Posts: 19
- Thank you received: 0
9 years 10 months ago #110564
by tischer_s
Replied by tischer_s on topic Randomnumber based variables
@DenisChenu:
May you please take a last look?
I am stuck with this error message...
Thank you very much for your help.
Best
Sebastian Tischer
May you please take a last look?
I am stuck with this error message...
Thank you very much for your help.
Best
Sebastian Tischer
The topic has been locked.