Display response for Checkbox Lookup Table

Dear Dimagi Forum,

It is possible to do the same as we know on KoboToolBox like "Display Response for Multiple Choice" but using "Checkbox Lookup Table"?

I'm using this formula for the "Multiple Choice Lookup Table" and works perfectly, but using multiple answers not shows anything:

Commcare formula:

concat(instance('table_id')/table_list/table[name = question]/label[@lang = jr:itext('lang-code-label')], "")

KoBo Toolbox Formula:

jr:choice-name(selected-at(${Q2}, 0), '${Q2}')

if (jr:choice-name(selected-at(${Q2}, 1), '${Q2}') = '', '', concat('
', jr:choice-name(selected-at(${Q2}, 1), '${Q2}')) )

if (jr:choice-name(selected-at(${Q2}, 2), '${Q2}') = '', '', concat('
', jr:choice-name(selected-at(${Q2}, 2), '${Q2}')) )

Selected options:
${Q2_abc_0} ${Q2_abc_1} ${Q2_abc_2}

Does someone know how I can resolve it?

Best regards,

concat joins the arguments together, so that function you have above joins a string with the empty string, which doesn't do anything.

Does the expression you have above work if only one option is selected? The reason it doesn't work is because of the [name = question] filter. That will only match entries in the lookup table whose name is the stored value of the question, but if multiple entries are selected, the stored value will be a space-separated list. I think instead you could do something like this

join(", ", instance('table_id')/table_list/table[selected(question, name)]/label[@lang = jr:itext('lang-code-label')])

join will combine multiple values into one, and the first argument is a separator - here I'm using a command and space, but you could use anything.
selected(question, name) checks whether name is among the values selected in question.

1 Like

Great! Works perfect! :slightly_smiling_face:

Thank you so much @Ethan_Soergel for your valuable support! :+1:

Dear @Ethan_Soergel

It is possible to show the "display label" or name (as Commcare is) of the previously selected question in the property case list?

When I call the "hidden value" in the property case doesn't show anything:

Best regards,

I'm not sure I follow exactly what you want to do, but you might be looking to use calculations in the case list:

https://confluence.dimagi.com/display/commcarepublic/Calculations+in+the+Case+List+and+Details

Thank you @Ethan_Soergel for your response.

I'll check it! (Y)

Best regards,

Dear @Ethan_Soergel

How should this formula be calculated to show the Display Text Field (label3) properly?

regst_gmina_label: concat(instance('Gmina')/Gmina_list/Gmina[name = #form/general_information/regst_gmina]/label[@lang = jr:itext('lang-code-label')], "")

These are the values that I'm using in my LookUp Table:

And this is the lookup table:

Best regards,

Hi

follow the instructions here for setting up your lookup table correctly for more than one language.
https://confluence.dimagi.com/display/commcarepublic/Using+Lookup+Tables+with+Multiple+Languages

the code jr:itext('lang-code-label') basically is a token that grabs the current label value in the form for the question lang-code. lang-code is where Dimagi instructs you to store the codes of the different languages. these codes need to match with the field property in the lookup table

your current lookup table does not have different languages set up from what I can tell. if you are only using one language in your app, the remove this piece from your code [@lang = jr:itext('lang-code-label')]

give it a shot

1 Like

Thank you so much for your support!

It was super useful.

Best,

1 Like