# Limit the number of iterations based on number given previous question

Repeat Group.xlsx (10.7 KB)
Dear members of this community
My name is Hadish Bekuretsion. First all, I would like to thank you for those who created this community support. And also my appreciation goes to for all the community members. When come to my point, I put as follows. I want to create a form as the following styles.

1. Family size: (User enters “4”)

For each family member, the following questions will be displayed:

#### For Person 1:

1. Name of Person 1: (User enters “John”)
2. Age of Person 1: (User enters “35”)
3. Sex of Person 1: (User selects “Male”)

#### For Person 2:

1. Name of Person 2: (User enters “Jane”)
2. Age of Person 2: (User enters “33”)
3. Sex of Person 2: (User selects “Female”)

#### For Person 3:

1. Name of Person 3: (User enters “Tom”)
2. Age of Person 3: (User enters “10”)
3. Sex of Person 3: (User selects “Male”)

#### For Person 4:

1. Name of Person 4: (User enters “Lucy”)
2. Age of Person 4: (User enters “8”)
3. Sex of Person 4: (User selects “Female”)

Welcome back to the community @hadish.

…to give automatic number sequentially.

Secondly the form has some errors which also require some fixing. You can use this Validation Tool.

1 Like

Thank You for your swift response. Let me explain in detail
I have the following questions.

1. Family Size in number_______
I want to record the following information for all family members. The questions are
1.1. Name of person
1.2. Sex for Person
1.3. Age in years for person
I want to give automatic numbering based on the family size. For example if the family size is 4. The number from 1 up to 4 should give to the family members based on their position.

@hadish I think I finally figured what you mean. Please take a look at the attached XLSForm Is this what you meant?
Repeat Group.xlsx (10.7 KB)

Some notes on what I did:

• created a new `calculate` question that uses the `position(..)` function to get the index of the iteration in the repeat-group in this case
• references that calculate field in the 3 questions that you require.

Here is a snapshot of the changes highlighted

Hope this is it.

2 Likes
1 Like

Yes, Sir… Thank you. It’s solved.