Calculation and begin group problem

1. What is the problem? Be very detailed.
In my survey form, I want to build a roster for all the HH members. From the roster, I want to calculate two variables one is "total female member" and other is "total family member who is in 15 to 50 age".
I want to use these two variables in section 8. Section 8 will appear if these two variables are greater than 0.

test.xls (170 KB)

See the documentation section on counting repeats and answers as well as the following example (the file and tables below are the same thing).

counting-values-inside-repeat.xlsx (10.2 KB)

+--------------------+-----------------+---------------------+------------------------+----------+------------+----------------------------------------------------+----------------------------+
|        type        |      name       | label::English (en) |   hint::English (en)   | required | appearance |                    calculation                     |         constraint         |
+--------------------+-----------------+---------------------+------------------------+----------+------------+----------------------------------------------------+----------------------------+
| begin_repeat       | member          | Household member    |                        |          | field-list |                                                    |                            |
| select_one genders | gender_member   | Gender:             |                        | yes      |            |                                                    |                            |
| integer            | age_member      | Age (years):        | (enter 999 if unknown) | yes      |            |                                                    | (.>=0 and .<=150) or .=999 |
| calculate          | member_female   |                     |                        |          |            | if(${gender_member} = 'female', 1, 0 )             |                            |
| calculate          | member_agegroup |                     |                        |          |            | if(${age_member}>=15 and ${age_member}<=50, 1, 0 ) |                            |
| end_repeat         |                 |                     |                        |          |            |                                                    |                            |
| calculate          | total_female    |                     |                        |          |            | sum(${member_female})                              |                            |
| calculate          | total_male      |                     |                        |          |            | count(${gender_member}) - ${total_female}          |                            |
| calculate          | total_agegroup  |                     |                        |          |            | sum(${member_agegroup})                            |                            |
+--------------------+-----------------+---------------------+------------------------+----------+------------+----------------------------------------------------+----------------------------+
+-----------+--------+---------------------+
| list name |  name  | label::English (en) |
+-----------+--------+---------------------+
| genders   | male   | Male                |
| genders   | female | Female              |
| genders   | other  | Other               |
+-----------+--------+---------------------+
2 Likes

Thank you for your reply. Still, the file is not working. It was given the following message during xls to xml conversion " Error: b'ODK Validate Errors:\n>> Something broke the parser. See above for a hint.\nDependency cycles amongst the xpath expressions in relevant/calculate\n\nThe following files failed validation:\n${test}.xml\n\nResult: Invalid' "

In my file, I had used position(..) in calculation column. In your file, you did not use it. Is there any problem if I have it in the xls file? I am attaching my update file after incorporating your suggestion. test.xls (170 KB)

It looks like you have other (unrelated) errors in your form that may be throwing this error. For example row 59:

select_multiple rel Q4_3 āĻ•ā§‡ āĻ¸āĻžāĻ§āĻžāĻ°āĻŖāĻ¤ āĻāĻ‡ āĻ¸āĻšāĻ¯ā§‹āĻ—āĻŋāĻ¤āĻž āĻĻāĻŋā§Ÿā§‡ āĻĨāĻžāĻ•ā§‡āĻ¨? (āĻāĻ•āĻžāĻ§āĻŋāĻ• āĻ‰āĻ¤ā§āĻ¤āĻ°) If yes, who usually provides that assistance? ${Q4_3}=1

ie the relevant expression for Q4_3 is: ${Q4_3}=1, which is obviously self-referencing ("I am only relevant if I'm 1... huh?" :slight_smile: ).

I'd advise going thru your form and checking anywhere you have a calculation, relevant, or constraint field to make sure they are in fact correct. @danbjoseph's answer is quite correct.