Summarizing previous answers from a multiple_select question in a note

Hello,
I am quite new to ODK and I would like to know if it is possible to summarize all given answers from a previous multiple select question in a new variable.

For example, we are asking which of the following crops the household harvested during the last 12 months. The respondent will get a list of 80 crops and can click as many crops as they harvested. Afterwards we would like to create a new variable in which we summarize all given answers: "You've reported that you harvested carrots, cabbage, pumpkins and cucumbers during the last 12 months. Is that correct?"

Can someone tell me, if this is possible to program and with which command using XLS?

Thanks!

Hi @sk1988
welcome to the forum! Please introduce yourself here!

here is a sample form I prepared for you: choice-name.xlsx (8.0 KB)
but if you have 80 items it will take some time to prepare a full form. I'm not sure if there is a better solution.

Thank you for your quick response.

I was hoping that there will be a different solution, but if you are also not sure if there is a better solution I will program it like that. I hope that the program is able to handle so many different items and will not slow down...

Thanks!

It might slow it down. Would it be possible to share your form? - I can try incorporating what I think might work in your case -

crops.xlsx (8.5 KB) alternatively, you can try the example in this file.

Thanks for your response and the document. I've tried your idea, but then only the numbers of the crops appear and not the labels. If you have an idea how to solve this issue it would be a good overall solution for me!

Here is the form, but as you said: it totally slows down!
crops_testdoc.xlsx (14.3 KB)

Just as a short update for people having the same question... It turned out that the choice-name option from @Grzesiek2010 is super, but unfortunately it is not 100% what I was searching for, since this is a dynamic command and when you want to summarize answer options separated by some categories (e.g. summarizing the harvested crops sep. by vegetables, fruits and spices) this is not working...

The alternative option from @Roxroy_Bollers is unfortunately also not working since the summarizing note is reffering to a select multiple question and then it seems to be not that easy to get the labels instead of the values.

But thanks for your responses and your ideas!

Please take a look at this form and see if it meets your requirements. It requires a new column in the choices sheet to represent the labels that you'll display in the summary. I named it my-label but it can have any name. It can be a direct copy of the label column. I explained the other unusual bits in a notes column.

The downside is that it won't work in a multi-language form. I can't think of a way to make that happen since I don't think we have XPath access to the itext block. We'd have to be able to apply jr:choice-name or jr:itext to all elements in a nodeset rather than to a single node.

3 Likes

join(", ", instance('test_list')/root/item[selected(${mult_select}, name)]/my-label)

Sheer brilliance! :star_struck:

2 Likes

Thank you very much @LN for your answer! This solution looks really great! Unfortunately, I am using a multiple language form, so maybe I will just forget about this stratified summary variable...

1 Like

I thought that might be the case, @sk1988! I’ll keep thinking about it — this is really something that should be possible.

@Xiphware would be brilliant if it were a full solution! Any brilliant insights on how to do the translations? I’m wondering whether translations should be yet another part of the spec we do a revisiting pass on.

1 Like

Makes sense. I dont really know the history of how itext translations support evolved (and I dont yet support them myself to fully understand the implementation subtleties involved), so I've been reluctant to chime in with any 'constructive opinions'... :wink: