Nested Repeat Groups? Using Lookup Table

Hello! I am working on a an app to monitor prices and have a look up table with the following fields: Commodity, Variety and Units.

I am trying to create a series of questions that within a repeat group such as:
Repeat Group (repeat count: based on number of commodities)

  • 1- Do you sell [Commodity1 ]?
    *1.1 - [if yes] Do you sell [Variety 1 of Commodity 1]?
    *1.1.1 - [if yes] how much does [quantity 1 of variety of commodity 1] cost?
    *1.2 - [if yes to "sell commodity]"] do you sell [variety 2 of commodity 1]?
    *2 - [if no], do you sell [commodity 2]?
    *etc

I have a repeat group with a model based on the lookup table, however, all the questions are repeated, so that question 1 (Do you sell [commodity]) is repeated before each question [do you sell variety 1,2,3,4, etc]. What I want is to be able to only ask that question once and then proceed with the variety and unit questions.

Is a lookup table the best way to do this? I tried nested repeat groups, multiple lookup tables, and display logic but somehow I can't figure this out.

Thanks,
V

Hi Veronica,

I'm guessing this logic will be a little complex, but it sounds like you want two nested repeats. If so, you may find it helpful to use a design pattern called "model iteration" to simplify the structure of your forms and provide some visibility.

I think your issue is that your outer loop wants to iterate over commodities, but your lookup table contains multiple entries with the same commodity since there are multiple varieties.

My recommendation would be to create additional lookup tables to provide just the iteration for Commodities, which you can then use as a filter into the Varieties table to iterate over the varieties for that commodity.

1 Like