Welcome to the LimeSurvey Community Forum

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

Question text depending on tokens and/or prior answers

  • FranzGerbig
  • FranzGerbig's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 8 months ago #122876 by FranzGerbig
Hi folks,

how may I present one out of two different question texts asking for the same numerical input - depending on tokens and/or answers to prior questions?
What I've been trying (and struggling with - don't mind the fictitious text examples but the syntax):

{If(q01 != 01) OR If(q02 == 01) "How many parents do you know?"}
{If(q01 == 01) "How many people do you know?"}

Please enter some number.

Thanks a lot

using LS 3.13.2+180709
The topic has been locked.
  • gabrieljenik
  • gabrieljenik's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 8 months ago #122879 by gabrieljenik
Please, see the IF function syntax in the following EM function list: manual.limesurvey.org/Expression_Manager#Implemented_Functions

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .

The following user(s) said Thank You: FranzGerbig
The topic has been locked.
  • FranzGerbig
  • FranzGerbig's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 8 months ago #122886 by FranzGerbig
sorry but I can't help it, still.

If(q01 != 01 or q02 == 01, "How many parents do you know?",
If(q01 == 01, "How many people do you know?",""),"")

The syntax if(test,result_if_true,result_if_false) applied to my case:
test (based on different questions each):
q01 != 01 or q02 == 01
result_if_true:
"How many parents do you know?"
result_if_false:
"How many people do you know?" - but only If(q01 == 01)
result_if_false (that is: none of above mentioned tests true):
Hide question!

As you see, I need to kind of combine relevance (works) and tailoring (doesn't work) - Can I do this with LimeSurvey?

Greets

using LS 3.13.2+180709
The topic has been locked.
  • gabrieljenik
  • gabrieljenik's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 8 months ago #122887 by gabrieljenik
Which error are you getting?
As per " I need to kind of combine relevance (works) and tailoring", you would need to use 2 expressions at relevance equation and also for tailoring.

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .

The following user(s) said Thank You: FranzGerbig
The topic has been locked.
  • FranzGerbig
  • FranzGerbig's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 8 months ago #122888 by FranzGerbig
any, I don't get any error :huh: :blink:

using LS 3.13.2+180709
Attachments:
The topic has been locked.
  • gabrieljenik
  • gabrieljenik's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 8 months ago #122892 by gabrieljenik
And what is what you get as output?

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .

The topic has been locked.
  • FranzGerbig
  • FranzGerbig's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 8 months ago #122911 by FranzGerbig
Hi Gabriel,

you mean, how the question appears on the survey page?
Well, the If(...) syntax appears as plain text in the question field (see attached jpg). Is this what you were asking for?
(However, the relevance equation works.)

Thanks for your engagement
bilo

using LS 3.13.2+180709
The topic has been locked.
  • gabrieljenik
  • gabrieljenik's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 8 months ago #122932 by gabrieljenik
About the formula locatd in the question texy, are you surronunding it with curly braces?
Also, please, check about case of the "if" function.

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .

The following user(s) said Thank You: FranzGerbig
The topic has been locked.
  • FranzGerbig
  • FranzGerbig's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 8 months ago #122948 by FranzGerbig
Hi Gabriel,

sorry - the very first time I entered the syntax with curly braces, LimeSurvey responded no valid syntax, so I took them out :whistle: :blush: .
Now, I noticed that the error was I had put "If" instead of "if". So now syntax with curly braces is OK, but doesn't work effectively.
... And after noticing that (using the default Yes/No-question type) "Yes" is the 'Y' and "No" is saved as 'N' (instead of 1 and 2) in the response data, the correct wording is presented for the correct condition.
Now it works perfectly - even with two "if"
{if(q01 == 'Y' or q02 == 'A1', "How many parents do you know?", "How many people do you know?")}

Muchas gracias - que estés muy bien
bilo

using LS 3.13.2+180709
The topic has been locked.
  • gabrieljenik
  • gabrieljenik's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 8 months ago #122955 by gabrieljenik
Great!

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .

The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose