Welcome to the LimeSurvey Community Forum

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

Process answer option "other" with expression

  • marco4960
  • marco4960's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 6 months ago #206009 by marco4960
Hi everyone,

I'm just starting to get familiar with expressions in Limesurvey and now I've ran into a problem I cannot solve myself - hopefully one of you guys can help me out with my problem.

Setup:
- QCODE1: Multiple Choice question with activated option "others"
- QCODE2: List question (drop down) with multiple answer options, one of these answer options is {QCODE1_other}. The remaining answers are regular strings.
- QCODE3, QCODE4, QCODE5: Questions that should refer to the choosen answer option of QCODE2 {QCODE2.shown}
- QCODE1 is in the first question group, all following questions are in the second question group.

The list question QCODE2 successfully displays the value of {QCODE1_other}, and all following questions successfully display the chosen option of QCODE2 with {QCODE2.shown} as long as one of the string answers is choosen.
Things start to fall apart when I pick the answer option of QCODE2 that refers to {QCODE1_other}, then all the following questions do not show the actual value of {QCODE1_other}, but "{QCODE1_other}".

Hopefully I described my problem properly.
Did anyone else run across the same issue and can maybe help me out?

Let me know if I should give additional information, any support is highly appreciated.

Thanks a lot and best regards
Marco
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 6 months ago #206010 by Joffm
Hi,
it's better you show us your survey (the relevant questions) as lss export.

So we know exactly what you did.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: marco4960
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 6 months ago - 3 years 6 months ago #206011 by tpartner
Replied by tpartner on topic Process answer option "other" with expression
Try this (assuming, for example, an answer code of "Q2Other" in Q2 for the other option):

Code:
{if(QCODE2 == 'Q2Other', QCODE1_other, if(!is_empty(QCODE2), QCODE2.shown, ''))}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 years 6 months ago by tpartner.
The following user(s) said Thank You: marco4960
The topic has been locked.
  • marco4960
  • marco4960's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 6 months ago #206013 by marco4960
Replied by marco4960 on topic Process answer option "other" with expression
Thanks for your suggestion - that did the trick for me :-)
Now everything works as expected.

Attached you find the question files (with problem in QCODE3 and solution in QCODE4).

Thanks again for your support!

Marco
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 6 months ago #206026 by Joffm
Hi, Marco,

let me mention two things.

1. In QCODE3 and QCODE4 you refer to QCODE2.
QCODE2 is not mandatory.
But you have no relevance equation in these following questions.
What I say is: Though you might not have a value of QCODE2 the following questions are displayed without the inserted data.
Like "Please answer the following question for the selected value"
In my opinion you should do this.
And then you can simplify the equation in QCODE4 to
{if(QCODE2 == 'AO04', QCODE1_other, QCODE2.shown)}


2. There is a reason why we always ask for LSS (survey) exports.
LSQ (question) and LSG (group) exports are language sensitive. So we have to create a survey with the correct base language to be able to import.
You can imagine what happens if someone sends an export with base language "Spanish(Argentina)" what nobody will expect.
Furthermore only an LSS export contains the general survey settings which may be quite important to find an error.
So a LSS export eases our voluntary work a lot.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose