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

More
1 month 3 weeks ago - 1 month 3 weeks ago #158096 by socius
socius created the topic: Filter array by a specific column from a multicolumn multiple-choice question
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: 1 month 3 weeks ago by socius. Reason: State subject more precisely.

Please Log in to join the conversation.

More
1 month 3 weeks ago #158116 by Joffm
Joffm replied the topic: Filter array by a specific column from a multicolumn multiple-choice question
Hi, socius,
please read the manual about
https://manual.limesurvey.org/Expression_Manager#The_reserved_.27this.27.2C_.27self.27.2C_and_.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
The following user(s) said Thank You: socius

Please Log in to join the conversation.

More
1 month 3 weeks ago #158119 by DenisChenu
DenisChenu replied the topic: Filter array by a specific column from a multicolumn multiple-choice question
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 service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
1 month 3 weeks ago - 1 month 3 weeks ago #158133 by socius
socius replied the topic: Filter array by a specific column from a multicolumn multiple-choice question
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: 1 month 3 weeks ago by socius. Reason: Integrated answers to all previous responses

Please Log in to join the conversation.

More
1 month 3 weeks ago #158136 by DenisChenu
DenisChenu replied the topic: Filter array by a specific column from a multicolumn multiple-choice question
Oups , didn't see it's you ( and thanks again for the fix).

With last version : you can use manual.limesurvey.org/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 service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
The following user(s) said Thank You: socius

Please Log in to join the conversation.

More
1 month 3 weeks ago #158139 by socius
socius replied the topic: Filter array by a specific column from a multicolumn multiple-choice question
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

Please Log in to join the conversation.

More
1 month 3 weeks ago #158144 by socius
socius replied the topic: Filter array by a specific column from a multicolumn multiple-choice question
Hi!

Thanks to @Joffm for the hint to the reserved "self." and "that." ( manual.limesurvey.org/Expression_Manager....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

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now