I am trying to filter answer choices for a multiple_select questions based on the answers from a previous multiple_select question (in our example, we are first asking about diagnosis of a participant and then based on this different choices for possible drugs the participant is taking should be displayed).
I used a category column in the choices sheet and a statement selected(${previous_var}, category) in the choice_filter column of the survey sheet. It works in the ODK online converter, but gives the following error message on CHT: message: “Could not evaluate: /model/instance[@id="other_drugs"]/root/item[selected( /model/instance[1]/cbl_main_bp_screening_test/oth_med_pr/t_other_dx , ‘category’)], message: Document.evaluate: The expression is not a legal expression”
name: “FormLogicError”
Does anyone have an idea how to solve this? Is there another way to use the choice filter function on CHT than I tried it?
It would be nice to know which CHT version you are using.
If you are using the latest version (4.x), then the selected() function in choice-filter should work:
However, if you are using 3.x version, then you can use another approach using contains:
Hi @felixgerber .I used contains(${pevious_choices}, choicesCategory} for version 3.x.x and it worked for me. I think 3.x.x uses an older version of enketo while 4.x.x uses a later version.
Thank you very much for your replies! We are using the latest CHT version, but we did not manage to make the selected() function in the choice-filter column work. However, the contains() function is doing the job!