Welcome, Guest Username: Password: Remember me

## Randomnumber based variables 4 months 4 weeks ago #110450

 tischer_s OFFLINE Fresh Lemon Posts: 19 Karma: 0 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 The administrator has disabled public write access.

## Randomnumber based variables 4 months 3 weeks ago #110467

 DenisChenu OFFLINE Moderator Lime Posts: 6551 Thank you received: 869 Karma: 257 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 Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?). A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous Official LimeSurvey Partner | Web development Last Edit: 4 months 3 weeks ago by DenisChenu. Reason: manual link The administrator has disabled public write access.

## Randomnumber based variables 4 months 3 weeks ago #110468

 tischer_s OFFLINE Fresh Lemon Posts: 19 Karma: 0 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 The administrator has disabled public write access.

## Randomnumber based variables 4 months 3 weeks ago #110474

 DenisChenu OFFLINE Moderator Lime Posts: 6551 Thank you received: 869 Karma: 257 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? ```{price=if(RANDOM== "1",0,1)} {storage=if(RANDOM== "1",2,1)}```et ... Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?). A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous Official LimeSurvey Partner | Web development The administrator has disabled public write access.

## Randomnumber based variables 4 months 3 weeks ago #110478

 tischer_s OFFLINE Fresh Lemon Posts: 19 Karma: 0 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?```{price=if(RANDOM== "1",0,1),if(RANDOM=="2",9,99),if(RANDOM=="3",19,99} {storage=if(RANDOM== "1",2,1)}``` The administrator has disabled public write access.

## Randomnumber based variables 4 months 3 weeks ago #110479

 DenisChenu OFFLINE Moderator Lime Posts: 6551 Thank you received: 869 Karma: 257 Please : read the doc .. manual.limesurvey.org/Expression_Manager ```{price=if(RANDOM== "1",0, if(RANDOM=="2",9, if(RANDOM=="3",19,99) ) )}``` Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?). A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous Official LimeSurvey Partner | Web development The administrator has disabled public write access. The following user(s) said Thank You: tischer_s

## Randomnumber based variables 4 months 3 weeks ago #110483

 tischer_s OFFLINE Fresh Lemon Posts: 19 Karma: 0 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": ```{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: Bildschirm...6.36.png (122KB) Last Edit: 4 months 3 weeks ago by tischer_s. Reason: Small typo The administrator has disabled public write access.

## Randomnumber based variables 4 months 3 weeks ago #110491

 DenisChenu OFFLINE Moderator Lime Posts: 6551 Thank you received: 869 Karma: 257 Because you allways need a 'if false' value.```{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 developpement are on my free time (Say thanks ?). A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous Official LimeSurvey Partner | Web development The administrator has disabled public write access. The following user(s) said Thank You: tischer_s

## Randomnumber based variables 4 months 3 weeks ago #110492

 tischer_s OFFLINE Fresh Lemon Posts: 19 Karma: 0 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 The administrator has disabled public write access.

## Randomnumber based variables 4 months 3 weeks ago #110564

 tischer_s OFFLINE Fresh Lemon Posts: 19 Karma: 0 @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 The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.390 seconds