result of hidden question depending on previous list question answer

More
3 years 2 months ago #130765 by VanEyck
Hi everyone! I'll try to be the clearest I can.

I have two questions, Q1 y Q2.
Q1 is a list of single options, which codes ares A1, A2, A3... and so on.

I need Q2 to be a hidden question, assigning a specific text response depending on which option was chosen in Q1.

For example:

if Q1 = A1
Then Q2= "NewYork"

if Q1= A2
Then Q2= "Washington"

and so on...

Is this possible??

Hoping for your kind advice!

Lucille

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
3 years 2 months ago #130766 by holch
Hmmm, I am wondering why you are not simply using "NewYork" as response code instead of A2?

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #130769 by VanEyck
Good question :)
Because Q1's options are neighboorhoods. I need to classify those neighboorhoods into cities, Am'I clear? Many of Q1's options will be classified as "New York"

Thank you!

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #130772 by holch
OK, this makes more sense then.

I would use a question type "relevance equation".

Read about Expression Manager, which will allow you to write if loops.

E.g.
{if(Q1=="Brooklin","New York")
if(Q1=="Manhattan","New York")
if(Q1=="Hollywood","Los Angeles")}
Code is not tested, but should be pretty close to how it works. Maybe some ";" mission somewhere, etc. Have a look at the syntax of Expression manager, there are loads of examples in the manual.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #130774 by VanEyck
Thank you Holch. Yeah, I've been reading the manual but to be completely honest, I've tried with every example's syntax with no positive result.

Which type of question should I use? Equation or list type?

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago - 3 years 2 months ago #130778 by holch

VanEyck wrote: Thank you Holch. Yeah, I've been reading the manual but to be completely honest, I've tried with every example's syntax with no positive result.

Hmmm, can't really believe that, because the first example on this page already shows how to write an if loop in EM... ;)
manual.limesurvey.org/Expression_Manager...ation.2FBranching.29

VanEyck wrote: Which type of question should I use? Equation or list type?


As said above, you need to use the equation type so that the recoded value get's stored.

So if you look at the example above in the manual, my code actually should work.
{
if(Q1==A1,"New York")
if(Q1==A2,"New York")
if(Q1==A3,"Los Angeles")
}

This should write "New York" into the equation type question if Q1 is A1 or A2.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
Last edit: 3 years 2 months ago by holch.

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #130780 by holch
Did a little test and it is working (see the attached question group).

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
Attachments:
The following user(s) said Thank You: VanEyck

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #130841 by VanEyck
Holch, thank you for your time.
I've tried the option
{
if(Q1==A1,"New York")
if(Q1==A2,"New York")
if(Q1==A3,"Los Angeles")
}

Didn't work. In the question group you attached, you used as logic operator symbol >. In that case it does work, but in the minute I replace that operator with "==" I'm unable to get right results.

I did read the manual and ran testes, It's not lack of will, it's lack of knowledge and experience :dry:

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #130854 by holch
With me "==" works fine as well.

However, your problem is that you are using answer codes that are not purely numerical, like I did.

In your case you will probalby have to write =="A1" to make it work. I might be able to have a look at it later.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago - 3 years 2 months ago #130891 by holch
Here a new example, using "A1" and "A2" as answer codes and it works:
Your city is: 
{if(G3Q1.NAOK == "A1", "New York", "")}
{if(G3Q1.NAOK == "A2", "Los Angeles", "")}

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
Attachments:
Last edit: 3 years 2 months ago by holch.

Please Log in or Create an account to join the conversation.

More
3 years 6 days ago #134840 by ledoux
Hi !
I have an issue that is close to this post. I will try to be clear.
I have many multi-items (array) tables with the same answer scale (each table has its scale).

I want to check if the respondent answers quickly without looking to the answers, only to go quickly to the end of the survey (check of "low quality answer").

I'm expecting to create a hidden question "equation" (let"s name it "test"), and I would like it to take the value "1" when the respondent checks the same answer on the scale for all the items of the table (and I will create a "test" for each table).
Imagine I have 2 items-question SQ1 and SQ2. And 2 values on the scale "1" and "2" for both SQ.
Then test=1 IF [(SQ1=1 AND SQ2=1) OR (SQ1=2 AND SQ2=2)], otherwise value is "0"

Is that clear ? I don't master enough the code, and reading the manual couldn't get this level of code....
thank you !!

New user of LS but with the will to contribute to this great community !

Please Log in or Create an account to join the conversation.

More
3 years 6 days ago #134845 by tpartner
This will return 1 if both answered rows of Q1 are the same, otherwise it will return 0.

{if(Q1_SQ1 != '' AND Q1_SQ1 == Q1_SQ2, 1, 0)}

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: ledoux

Please Log in or Create an account to join the conversation.

More
3 years 6 days ago - 3 years 6 days ago #134890 by ledoux
Tpartner, thank you !
In your exemple, "Q1" is the question's code, that's it?

Suppose I have 4 items (rows), then it will be
{if(Q1_SQ1 != ' ' AND Q1_SQ1 == Q1_SQ2 == Q1_SQ3 == Q1_SQ4, 1, 0)}

that's it?

If I don't want to introduce the condition "answer must be filled", then I take off (Q1_SQ1!=' ') that's it?
thank you!!

New user of LS but with the will to contribute to this great community !
Last edit: 3 years 6 days ago by ledoux.

Please Log in or Create an account to join the conversation.

More
3 years 6 days ago #134891 by ledoux
Tpartner
complentary : let's suppose I have 4 items in the table. Then if the respondent forget to check one radio button but answers the same "column" (scale answer) for all the other items. Then I would like to attribute value 1 to the hidden test-variable.
do you know how it this feasible (seems complicate to code...) ?
Thank you

New user of LS but with the will to contribute to this great community !

Please Log in or Create an account to join the conversation.

More
3 years 5 days ago - 3 years 5 days ago #134919 by tpartner

Suppose I have 4 items (rows), then it will be
{if(Q1_SQ1 != ' ' AND Q1_SQ1 == Q1_SQ2 == Q1_SQ3 == Q1_SQ4, 1, 0)}

that's it?

No.
{if(Q1_SQ1 != '' AND Q1_SQ1 == Q1_SQ2 AND Q1_SQ1 == Q1_SQ3 AND Q1_SQ1 == Q1_SQ4, 1, 0)}


complentary : let's suppose I have 4 items in the table. Then if the respondent forget to check one radio button but answers the same "column" (scale answer) for all the other items. Then I would like to attribute value 1 to the hidden test-variable.
do you know how it this feasible (seems complicate to code...) ?

I don't understand the question. I thought the requirement was to insert 1 into an equation question if all answers are the same.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 years 5 days ago by tpartner.
The following user(s) said Thank You: ledoux

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!