Kobo–matrix_list conditional variable list

Hello everyone!

I have a question about the kobo–matrix_list function. I would like the list of items that appear in my table below to be the options selected in the previous questions. For example, if you marked eggs, Milk, Potato, tomato, banana and apple, these items should appear in the table below to complete the price and quantity.

thanks for your support.

Welcome @christian_silvera,
Did you try the relevant clause?

1 Like

Thanks @wroos

Yes, I have seen some examples of skip logics but they are too simple for what i need. I would like that in my matrix below only the items that the participant has marked in the previous questions appear.

Hello!

I was able to make the options that are marked in the previous questions but when I mark more than one option, everything is filled in the same box. What I did was put ${variable1} in the labels column in the choices sheet.

thanks

@christian_silvera, the skipping for a select_one question and select_multiple questions are different. Maybe you will need to try it with the latter one. That should help you solve your issue.

Hello,
As you reference a multiple_select you need to use selected(…), see https://getodk.github.io/xforms-spec/#fn:selected.

Multiple selected choices are stored in a sring, separated by space. That is what you got now with ${variable1}.

2 Likes

Hi @christian_silvera @Kal_Lam
Is it possible to send the xls file with solutions?, have same requirements with issue that you raised

Maybe something similar., but for Collect, was discussed here already (found with the recommended search function of this forum).
https://community.kobotoolbox.org/t/alternative-of-question-matrix/1850

1 Like

Piggybacking as I have this exact problem!
Sorry, are you able to be more specific about the syntax that I need to use here? I have been reading and guessing for an hour now based on the thought that I needed to put “selected(${variable1})” in the labels column on the choices worksheet.
This just prints the equivalent of “selected(apio perejil papa cebolla)” as the label for a single row…

As an additional note, I am hoping to pull the choice labels here rather than names. I found some documentation relating to this, but wasn’t able to understand how to implement it in my case.

Many thanks!!

@BecSCS, you should be able to use the skip logic in a matrix question as outlined in this support article:

@BecSCS Getting back to you as I bumped into a similar situation and found a way to work with it, so hopefully it can be useful.

For example, you use select_multiple for varA, and want to refer what selected to the upcoming matrix, then I used those steps:

  1. calculate selected options into a new variable, (in the survey tab) calculation = selected-at(${varA},(position(..)-1))
  2. Call out the names of selected options into a new variable varA_selected (in the survey tab) calculation = jr:choice-name(selected-at(${varA},(position(…)-1)),‘${varA}’)
  3. Use the names to refer in a matrix: (in survey tab) kobo--matrix_list = varA_selected, and (in choices tab) varA_selected label = ${varA_selected}

Thanks. Would be great if you can provide/add a small form example here.

Hello, would you please share a sample XLS form for the applied steps.
I am trying to do something similar to this. Many thanks