Welcome to the LimeSurvey Community Forum

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

Auto-generate data into hidden question and then reference it in another Q

  • Winocll_48635
  • Winocll_48635's Avatar Topic Author
  • Offline
  • Banned
  • Banned
More
7 years 9 months ago #138112 by Winocll_48635
My ultimate goal is to generate data into a hidden question. Then, depending on that generated data hide a particular group within the survey. Since i couldn't get that to work i decided to display the data that is supposed to be generated into the hidden question. But rather than any data appearing the equation itself appears.

The hidden question to receive generated data is called "qspcode" and it looks like this...

question type: equation
mandatory: no
always hide question: yes
equation: {qspcode=if(TOKEN:ATTRIBUTE_1 == "001", "1", if(TOKEN:ATTRIBUTE_1 == "002", "2", if(TOKEN:ATTRIBUTE_1 == "003", "3", if(TOKEN:ATTRIBUTE_1 == "004", "4", if(TOKEN:ATTRIBUTE_1 == "005", "5", if(TOKEN:ATTRIBUTE_1 == "006", "6", if(TOKEN:ATTRIBUTE_1 == "007", "7", "8"))}


The question that is supposed to display the data generated into qspcode looks like this...

question source:

CS1. Thinking about {INSERTANS:197459X108X2371}, please rate your likelihood to recommend them to friends or family on a scale where 0 is "Not at all Likely" and 10 is "Very Likely".
{INSERTANS:197459X108X2473}


question as it displays before clicking the "edit" icon:

CS1. Thinking about util.shown, please rate your likelihood to recommend them to friends or family on a scale where 0 is "Not at all Likely" and 10 is "Very Likely". qspcode.shown


The token table that contains ATTRIBUTE_1 (spcode) looks like this...



The question text as it displays during testing is...
The topic has been locked.
More
7 years 9 months ago - 7 years 9 months ago #138115 by steve_81
Hi,

I guess there is something wrong in your equation itself. Try this in your qspcode:
Code:
{if(TOKEN:ATTRIBUTE_1 == "001", "1", if(TOKEN:ATTRIBUTE_1 == "002", "2", if(TOKEN:ATTRIBUTE_1 == "003", "3", if(TOKEN:ATTRIBUTE_1 == "004", "4", if(TOKEN:ATTRIBUTE_1 == "005", "5", if(TOKEN:ATTRIBUTE_1 == "006", "6", if(TOKEN:ATTRIBUTE_1 == "007", "7", "8")))))))}

This should give you the transformed value of the Token.

In the question CS1 you can refer simply per {qspcode} to get the new value (easier than these insertans).
What is the second insertans in your CS1?

To hide a whole group you can use the relevance equation. Just insert {TOKEN:ATTRIBUTE_1 == "006"} and this group will only be displayed for the spode/spcode 006.

Greets
Steve
Last edit: 7 years 9 months ago by steve_81.
The following user(s) said Thank You: Winocll_48635
The topic has been locked.
  • Winocll_48635
  • Winocll_48635's Avatar Topic Author
  • Offline
  • Banned
  • Banned
More
7 years 9 months ago #138123 by Winocll_48635
Thanks so much...that really helped!
I was trying to get groups of questions hidden under certain circumstances, and you helped with that as well. For some reason i thought i needed to use an 'if' statement in the relevance equation...ugh.

Thanks again for helping me fix my issue :)
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose