Concatenating and generating IDs for every member of a household

Hello colleagues,
I've been building a form for a ward-level census. So far its 90% completed, however, I still have some challenges, especially with generating IDs for the household members. So far, I've been able to concatenate the structure ID, dwelling ID and household ID to try and generate an ID for each HH member. The problem is that the same ID keeps being generated for different household members no matter the number. e.g if after concatenating, the ID for the first member is 001-02-02-01, the ID for the next person should be 001-02-02-02 but I still keep getting the same ID number i.e. 001-02-02-01 for all the household member. I've attached a snippet of the form. Would appreciate some guidance on this. The area in question is coloured 'yellow'.snippet for ODK forum.xlsx (10.4 KB)

I think (haven't tested it), that you should be able to use position(..) to "identify the current iteration index within a repeat group" and that is what you need to complete your ID?

See https://docs.opendatakit.org/form-operators-functions/#control-flow

1 Like

Thanks Joseph. Do I add this to the concatenate code under the 'calculation' column?

I think so. Sorry I don't have a clearer idea! Please post here the results if you test it.

Will definitely do. Thanks

Hello Joseph. I got some results, however, I'm still having challenges with the way the person ID appears. The sequence of numbers automatically generated doesn't conform with how I intend the ID to look like e.g. the sequence appearing in twenties and thirties. The only way I was able to get close to what I want was to ensure that the Structure IDs, Dwelling IDs and Household IDs are manually entered by the data collector while the person ID is auto-generated by concatenating the IDs specified above. I would appreciate some insight into how best to use the position(..) logic.

Thanks

If possible, can you please post the lines from the survey that are building the ID? And an example of the data output showing the mismatch between what is being created and what you are looking for?

See this for details on how to share a snippet of an XLSForm: