Welcome to the LimeSurvey Community Forum

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

Array Filter and conditional question

  • jyu183
  • jyu183's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 1 month ago #226509 by jyu183
Please help us help you and fill where relevant:
Your LimeSurvey version: [3.27.26]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
Hi everyone, I am new to LimeSurvey and would like to borrow your wisdom for the matter I am completely struggling with!

I would like to make Question 2 appear based on the answers from Question 1, but only selectively. For instance, please see attached the screenshot. I am using Array for Q1 and Multiple Choice with comments for Q2 (and using Array Filter with the code of Q1), and Q2 is based on the answers I selected in Q1. Problem is, whether I select just "challenges" or "most pressing challenges", they both appear in Q2 anyway. But what I want is that only the answers I choose as "most pressing challenges" will appear in Q2 - ignoring whatever I mark as "challenges". 

Would this be solvable by basic functions? Or should I use some script or Expression Manager? I suspect it's the latter, but as I am completely new to the software, I would like to ask for your advice. Would really appreciate your help! 
 
Attachments:

Please Log in to join the conversation.

  • tammo
  • tammo's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
3 years 1 month ago #226510 by tammo
Replied by tammo on topic Array Filter and conditional question
Yes, the Expression script on subquestion level is easiest.

Please see the attached example.  

File Attachment:

File Name: arrayfilter.lss
File Size:24 KB


Also (for short time) visible at:  research.respondage.eu/index.php/226316?newtest=Y&lang=en


Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl

Please Log in to join the conversation.

  • jyu183
  • jyu183's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 1 month ago #226511 by jyu183
Replied by jyu183 on topic Array Filter and conditional question
Thanks so much - this is EXACTLY what I need!

But since I am a total novice here (sorry!), I am still a bit confused as to how to implement this. I've downloaded your sample but could not see any script or code in there. Do I use "relevance equation" function? Or "script"?

Or would there be a detailed guide of how to perform the Expression script on subquestion?

Sorry for bombarding with questions...

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago - 3 years 1 month ago #226513 by Joffm
Replied by Joffm on topic Array Filter and conditional question
Hi,
but you saw this
 
as @Tammo wrote,
use the relevance on subquestion level as you see in the manual
[url] www.limesurvey.org/manual/Adding_answers...fic_for_subquestions [/url]

I recommend to read the manual, at least about "question types" and "ExpressionScript"
[url] www.limesurvey.org/manual/Question_types/en [/url]
[url] www.limesurvey.org/manual/Expression_Manager/en [/url]
and to study the sample surveys
either by downloading and importing them
[url] www.limesurvey.org/manual/Expression_Manager_sample_surveys [/url]
or in the demo installation (though the demo uses Limesurvey 5.x. with a changed GUI)
[url] demo.limesurvey.org/admin [/url]

And a last word.
In my opinion you should use a question of type "multiple short tex" in your second question.
You ask "Tell me more about these items " and not "Please select, and then comment the now selected items" 
But it is your survey and you decide.

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 1 month ago by Joffm.
The following user(s) said Thank You: jyu183

Please Log in to join the conversation.

  • tammo
  • tammo's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
3 years 1 month ago #226515 by tammo
Replied by tammo on topic Array Filter and conditional question
I agree with Joffm!


Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
The following user(s) said Thank You: jyu183

Please Log in to join the conversation.

  • jyu183
  • jyu183's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 1 month ago #226526 by jyu183
Replied by jyu183 on topic Array Filter and conditional question
Thank you so much Joffm (and to tammo too); this is incredibly helpful. I am studying the other samples too; thanks also for your suggestion of references, they have been great!

Just one last question if I may: I tried to switch the format from Array to Array (Number) as I wanted to use the checkbox function so that respondents can mark "at the same time" both "challenges" and "most pressing challenges". But apparently this doesn't seem to work, because I guess Array Number format has two axes of subquestions with no answer, so the code seems to clash.

From my quick search in the forum, it seems this is not possible without using script hack; but just in case I am asking, might there be a way to make Array Number (with checkbox) format works in the same way as Array did? If there is not, that is fine, but I just wanted to make sure if that would be possible.

Alternatively, I wonder if it would be possible to use Array and make it possible for respondents to select "both" challenges and most pressing challenges.

Sorry for throwing out the questions; I hope this is not too much of trouble on your side.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago #226531 by Joffm
Replied by Joffm on topic Array Filter and conditional question
No. this works exactly the same way in ALL questions with subquestions.

On the other side:
Why this question type?
If somebody clicks "most pressing" in your "normal" array, it is obvious that it is a "pressing" challenge; in my opinion no need to check both.

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • jyu183
  • jyu183's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 1 month ago - 3 years 1 month ago #226532 by jyu183
Replied by jyu183 on topic Array Filter and conditional question
I see, so it will not be possible to use Array Number because it contains two subquestions (X and Y axis), unlike in Array?

I was asking about Array Number Checkbox, because I would like to allow respondents to be able to check and uncheck the box - apparently this is not possible in the Array format without using script (adding a reset button). Once an answer is chosen, you cannot unchoose it apparently. 


 
Last edit: 3 years 1 month ago by jyu183. Reason: Having a question

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago #226549 by tpartner
Replied by tpartner on topic Array Filter and conditional question
With array-numbers, you can place relevance on the Y-scale sub-questions. It is also a good practice to use different codes for X and Y scales.

 

Cheers,
Tony Partner

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

Please Log in to join the conversation.

  • jyu183
  • jyu183's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 1 month ago #226556 by jyu183
Replied by jyu183 on topic Array Filter and conditional question
Thanks Tony, but I am afraid this did not work. Here is what I tried:

(1) Question 1 is Array Number (with checkbox display).

(2) In subquestions for Question 1 (code: PH1), I gave codes SQ001 - SQ004 to the 4 subquestions on Y-Scale, and codes X01 and X02 to the 2 subquestions on X-Scale.

(3) Then in Question 2 (multiple short text), I set 4 subquestions, adding to each relevance equations: PH1_SQ001=="X02"; PH2_SQ001=="X02"; and so forth.

(4) This resulted in an error in Question 2, when I ran logic check, with PH1_SQ001 being "Undefined variable". The result is Question 2 appears from the beginning rather than being condition on the answers from Question 1.

I assume this occurred because, at the moment, there are TWO different types of subquestions in Question 1 - X and Y Scales. I went through the relevance equation part on manual but still not clear how to resolve this issue. Any advice would be really appreciated...

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago - 3 years 1 month ago #226562 by Joffm
Replied by Joffm on topic Array Filter and conditional question

PH1_SQ001=="X02"; PH2_SQ001=="X02"; 

Please, read here about the coding
[url] www.limesurvey.org/manual/ExpressionScri...code_variable_naming [/url]

I always recommend to activate your survey, enter some - well defined - data (meaning: write down, what you entered) and have a look at the answer table.
Here you see, how to access the variable and which code to use.

In short:
An array(number has two dimensions - y-axis and x-axis.
And you have to use both to define a cell
So you access the cell in the first row, second column by (with your coding)
PH1_SQ001_X02

Furthermore you would see in the answer table that this type of question stores data as
"1" : selected

So the relevance equation has to look like this
PH1_SQ001_X02==1

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 1 month ago by Joffm.
The following user(s) said Thank You: jyu183

Please Log in to join the conversation.

  • jyu183
  • jyu183's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 1 month ago #226568 by jyu183
Replied by jyu183 on topic Array Filter and conditional question
This is amazing; thank you Joffm (and everyone), I cannot express how much I appreciate your help (and patience)! It has solved my problem.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose