Filter Multiple-Choice Question with Cases as Values by Selected Parent

I have a case called ‘Project’, which has an ‘Indicator’ child case. In the indicator details form (which you can access by first selecting a project and then selecting an already registered indicator), you can select which other indicators from the same project the currently selected indicator relates to.

I have a lookup table set up with the following statement:
instance(‘casedb’)/casedb/case[@case_type = ‘Indicator’][index/parent=current()/@case_id][@status = ‘open’]

This, unfortunately, results in a question with no choice values. If I remove the [index/parent=current()/@case_id], it return all open indicator cases, which is not what I want.

Thanks for your help on this!


Hi Ralph,

I think the confusion is in where you are trying to derive the ID of the case that was selected from the menu.

The current() root in an XPath expresson makes a reference to the context of the current question, rather than the “Current” Case that was selected.

The case selected in a menu is generally available from the session instance, with a reference like


Can you update your reference to retrieve the case id in that manner and see if it corrects the issue?


Thanks Clayton. I tried the following:

instance(‘casedb’)/casedb/case[@case_type = ‘Indicator’][index/parent=instance(‘commcaresession’)/session/data/case_id][@status = ‘open’]

but the question remains empty of choice values.


Hi Ralph,

I read your question again to make sure I was clear, since I think I mis-interpreted on the first reading.

Are you looking for cases with a “peer” relationship? IE: other indicators which share the same parent as the selected indicator?

If so, instead of searching for cases which index the current case ID (which will give you a list of child cases) you should search for cases which have the same parent id as the current case, which (as outlined on that page) you can retrieve as follows:

instance(‘casedb’)/casedb/case[@case_id = instance(‘commcaresession’)/session/data/case_id]/index/parent

I’d recommend putting that lookup in a hidden value before loading it into the lookup table question to filter the case list, since it’ll be complex.


This worked perfectly! Thanks Clayton!

Copying your solution and pasting it throws error with a bit vague error report. If anyone trying this, gets an error, the solution is typing the single quotations marks.

Copy paste will give you- curly quotations ‘’.
Typing will give you straight quotation