Get position of repeat group based on variable value

1. What is the problem? Be very detailed.
A colleague of mine reached out with inquiry on possibility to return the name of the HH member with minimum age within the roster. In my opinion, the simpler solution would have been to be able to find the repeat position where the value of a specific variable within that repeat was equal to a a criteria (tricky part being age is a dynamic value)

3. What you have you tried to fix the problem?
Since indexed-repeat() retrieves values at a specific position of a repeat, can I retrieve the position based on value? this value can be made unique by combining value and position using "concat(${var}, '-', position(..))". With position that corresponds with values (in this case minimum age) then I could do reverse process and use indexed-repeat() to retrieve the name of the hH member. At this stage, I wasn't worried about scenarios where there might be more that one member with minimum age.

Alternative solution was to:

  • Calculate minimum age with min(${age})
  • Create another repeat to loop through the HH member roster with if(${temp_age} = ${min_age}, ${temp_name}, "") and finally
  • Calculate a template holder for all names with age = min_age using join(' ',${min_names})

Above calculations used indexed-repeat(), however, I have a feeling this was tedious

Anyone with a better/shorter approach?