Welcome to the LimeSurvey Community Forum

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

Filter array by a specific column from a multicolumn multiple-choice question

  • socius
  • socius's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
7 years 2 months ago - 7 years 2 months ago #158096 by socius
Dear all,

I'd like to filter an array by a multicolumn (actually 2 cols) multiple choice question, more concrete:

I have an array (numbers) in multiple choice/checkbox (0/1)-mode with two columns (and n rows) - lets call this array (q0), with variables q1_(1:n)_1 and q2_(1:n)_2. (Substantially I ask for a number of n activities (=rows) whether the respondents engage in these activities on weekdays and/or weekends (=2 columns, multiple choice)).

The subsequent two questions then are about the duration of these engagements on (q1) weekdays and on (q2) weekends respectively. So I have to filter and show only activities the respondents are engaged in on weekdays and weekends resp. I could filter each subquestion of q1 and q2 with specific relevance eqations for each row and the q0 weekdays / weekends, e.g. relevance equation for the first row of q1 is q0_1_1 == 1, for the second row q0_2_1 == 1, etc.

But as this is tedious when n is large: Is there a way to use the columns of q0 directly as array filter, something like q0_(1:n)_1, where (1:n) is a wildcard for all rownumbers?

Thanks a lot for your time!
Best, G
Last edit: 7 years 2 months ago by socius. Reason: State subject more precisely.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 2 months ago #158116 by Joffm
Hi, socius,
please read the manual about
www.limesurvey.org/manual/Expression_Man....27that.27_variables

Maybe you can use it.

On the other hand it is not to tiresome to create the equations, if you do it in EXCEL or OpenOffice just with a formula.

Regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: socius
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
7 years 2 months ago #158119 by DenisChenu
Because LimeSurvey relevance functionnality must work with javascript : it's not included for column.

This functionnality have a plugin (as a workaround) extensions.sondages.pro/questions-updati...ing/hideemptycolumn/

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
  • socius
  • socius's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
7 years 2 months ago - 7 years 2 months ago #158133 by socius
Hi @Joffm,

thanks your for that hint - did not know about this and self and it looks really promising - I'll try and return with my experience.

And: yes also thanks for the suggestion to create equations via spreadsheets - I do that, but the slow thing here is more the copying of the single relevance equations into the question. The array filter would be a quicker solution and it's also easier to handle in case of errors, changes etc.

@DenisChenu: Thank you for you response - I already use your very helpful plugin :-) In this case I do not want to filter out columns, but I want to use single colums of multiple choice arrays as array filter for subsequent questions.

Best, G
Last edit: 7 years 2 months ago by socius. Reason: Integrated answers to all previous responses
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
7 years 2 months ago #158136 by DenisChenu
Oups , didn't see it's you ( and thanks again for the fix).

With last version : you can use www.limesurvey.org/manual/Adding_answers_or_subquestions relevance on subquestion. q1_1_2=="Y" ,q1_2_2=="Y" etc … (order 1 and 2 can be reviewed : i always make error and don't remind if it's X_Y or Y_X).

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The following user(s) said Thank You: socius
The topic has been locked.
  • socius
  • socius's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
7 years 2 months ago #158139 by socius
Thank you!

Concerning the confusion with the order of X_Y: same with me :-) I always remember from maths that the fi"R"st number means the "R"ows - I hope I'm right ;-)

In Limesurvey it would be great if we could add the relevance equations just like "code, questiontext, relevance" - I discussed that in another topic, but did not add it to the wishlist yet.

Best, G
The topic has been locked.
  • socius
  • socius's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
7 years 2 months ago #158144 by socius
Hi!

Thanks to @Joffm for the hint to the reserved "self." and "that." ( www.limesurvey.org/manual/Expression_Man....27that.27_variables ). I read the manual and tried to apply these for this purpose (I want to use a specific column from a multi-column array as an array filter for a subsequent question), but that does not seem too easy (to me).

I took my example with n rows and 2 columns, ticked three items in column "X2" and tried functions sum, implode, join and list:

sum: {sum(that.q1.sq_X2.NAOK)} # gives 3
implode: {implode('', that.q1.sq_X2.NAOK)} # gives 111
join: {join(that.q1.sq_X2.NAOK)} # gives 111
list: {list(that.q1.sq_X2.NAOK)} # gives 1, 1, 1

These results do not look too bad. But the questions are:
(1) how does a variable for an array filter have to look like? 00110001110? or NNYYNNNYYYN? Or ...?
(2) Is there a function among the EM functions that could achieve this and transform a column in the necessary form?
(3) Could we use the output of a function like {func(that.q1.sq_X2.NAOK)} directly as an array filter variable?

Lots of questions here ;-)
Thanks a lot for your time!
Best, G
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose