Filtering data in lookup table located inside a Repeat Group

Hello,

I am using a Lookup Table Data inside a Repeat Group and I am populating family members inside the lookup table (with a certain criteria). It iterates and lets the user fill info for each member. When it does that, I want to remove the members already selected and list the members not processed inside the lookup table whenever the repeat group works. For example, if there are 3 members (MemberOne, MemberTwo and MemberThree), if the user selects MemberTwo first, I want to display MemberOne and MemberThree only on the next iteration. I tired many ways, but none of them work.

I would appreciate any help.

Mariawit

Hi,

Unfortunately this interaction (a “Burndown list”) is a pretty tricky fit with the XForms model, because the form needs to be able to keep the list of selection choices accurate for both future and historical lists. You can “lock in” the previous choice when the next repeat is created by using join() to create a space separated list of all non-selected values, then using that as the default value for a hidden value inside of the repeat. That list would let you filter the choice list (using not(selected() ) to remove items which were chosen when the repeat was created. That can introduce issues, however, if the user changes a historical choice: The form won’t update the future select lists to reflect the new state.]

It’s less elegant, but simpler, to simply not allow the user to select choices which have already been used. That’s a much more straightforward pattern which you can see by copying and pasting the following text into the HQ form builder to build the form

Form Builder clip version 1
id type labelItext:en-default labelItext constraintMsgItext:en-default appearance calculateAttr constraintAttr constraintMsgAttr rawDataAttributes
/repeat_unique_selection Group null null null null null null null null
/repeat_unique_selection/question1 Trigger This form won’t let you pick the same value more than once in the repeat question null null minimal null null null null
/repeat_unique_selection/questions Repeat Repeated Questions null null null null null null “{”“jr:template”":""""}"
/repeat_unique_selection/questions/filter_question Select Which group are these questions about? question2/filter_question-label You already used this value! null null not(selected(#form/repeat_unique_selection/repeat_checker, .)) jr:itext(‘repeat_unique_selection/questions/filter_question-constraintMsg’) null
/repeat_unique_selection/questions/filter_question/a Choice A question2/filter_question-a-label null null null null null null
/repeat_unique_selection/questions/filter_question/b Choice B question2/filter_question-b-label null null null null null null
/repeat_unique_selection/questions/filter_question/c Choice C question2/filter_question-c-label null null null null null null
/repeat_unique_selection/repeat_checker DataBindOnly null null null null “join(”" “”, #form/repeat_unique_selection/questions/filter_question)" null null null

Thank you for your reply Clayton. I have already tried the first solution you suggested. It does not work for me, because, it keeps resetting the value whenever the repeat group iterates.
I am trying the second solution. it does not seem to work. May be I haven’t clearly understood what you meant. Can you elaborate it more?

Thank you

The second solution is essentially just enforcing that the lookup table question has a unique answer in each repeat (IE: there are no duplicates)

There’s a good recent discussion of how to do that in another forum post which could be helpful: https://forum.dimagi.com/t/avoid-duplicates-in-repeat-group/7697/7

-Clayton

I have followed the suggestion on the forum and it works now. Thank you.