Welcome to the LimeSurvey Community Forum

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

result of hidden question depending on previous list question answer

  • VanEyck
  • VanEyck's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 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
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 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 answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • VanEyck
  • VanEyck's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 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!
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 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.
Code:
{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 answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • VanEyck
  • VanEyck's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 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?
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 2 months ago - 8 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.
Code:
{
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 answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Last edit: 8 years 2 months ago by holch.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 2 months ago #130780 by holch
Did a little test and it is working (see the attached question group).

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: VanEyck
The topic has been locked.
  • VanEyck
  • VanEyck's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 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:
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 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 answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 2 months ago - 8 years 2 months ago #130891 by holch
Here a new example, using "A1" and "A2" as answer codes and it works:
Code:
Your city is: 
{if(G3Q1.NAOK == "A1", "New York", "")}
{if(G3Q1.NAOK == "A2", "Los Angeles", "")}

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Last edit: 8 years 2 months ago by holch.
The topic has been locked.
More
7 years 11 months 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 !
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #134845 by tpartner
This will return 1 if both answered rows of Q1 are the same, otherwise it will return 0.

Code:
{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
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose