Referencing Columns in CommCare – How to Use Lookup Table in Display Condition

commcare

I have a question in my form that references a lookup table. If the user chooses a a specific answer from that multiple choice question, I would like to conditionally display a text entry question for follow up.

In order to do this I want the text field to display if a column in the lookup table is equal to '1' or 'True' in a specific column. For each possible answer choice in the lookup table this column is either 1 or 0. If the answer choice = 1 for that column, I would like the text field to display.

How can I reference this specific column in the lookup table in the display condition for the follow up text entry question?

Best Answer

If I understand correctly you'll want to do:

instance('my_lookup_table')/my_lookup_table[category_column = /data/my_select_question]/value_column = 1

where:

  • my_lookup_table: the name of your lookup table
  • category_column: the column in your lookup table that matches the select list answer
  • data/my_select_question: the question the user answers
  • value_column: the column that holds true/false values

This filters the table to get just the row that matches the selected item. Then checks if the true/false column is true/false.