In a group with repeatation want to count age group

Dear,

I have created a survey form for house hold members. I am using group having repetition because I don’t know how many member is there. I want to count their age group at the last of finishing entry group data.

Can u pls help me in this regard. Thanks in advance.

@asif_rahman_joy, you could do that as discussed in our previous post:

Dear Kal_lam,

That is great!! “repeat_count” is very good attribute. Thanks a lot.
But I have different problem. May be I could not clarify it properly.

My problem is:

I have a repeated group where I am entering data of house hold members. Now, I have three age group: below 5, 5 to 14 and above 14.
When I entering age, I am using “calculate” to define this group. But at the end of group, I have to count

  1. how many members are under 5 years
  2. how many members are 5 to 14 years
    and
  3. how many members are above 15

Please help me regarding this.

Thanks a lot for your quick response and cooperation.

Asif R Joy

Hello @asif_rahman_joy,

Recently I have to do a similar thing that might help you.

I’m suggesting to define some if conditions for all of the age groups, and summing up at the end of the form.

For example adding calculate questions for your age groups, like if( {age} <5, 1, 0 ) will result in 1 if the age is below 5 and 0 otherwise -which you can sum at the end of the form-

You might want to check these articles:
First article which shows how to create Dummy Questions and the second one shows the form operators

Hope this helps,

https://support.kobotoolbox.org/advanced_calculate.html#work-arounds-for-calculations

https://docs.getodk.org/form-operators-functions/

1 Like

Dear hakan_cetinkaya,

Thanks for your response and help.

Earlier I had tried that one. It is helpful but not in repeat group.
I am working with position(…), join and count function. May be it will work, If it works then I ll let you know.

Thanks

Asif R Joy

Hi @asif_rahman_joy

I think it works in a repeat group too. But it might seem a little off :slight_smile: You made me so curious, I designed the following:

Note that I’m calculating the corresponding age group inside the repeat group and summing them all outside the group.

It works like this:

You can also test it yourself in here:
https://ee.kobotoolbox.org/x/Rjvlrq5X

Also reference xlsform:
Age Count.xlsx (9.6 KB)

Best,

1 Like

Dear @hakan_cetinkaya,

Wow!! That’s great!!
Last 2 days I was struggling with same logic but I was using count() function. And then I carried away and I have started using position(), join() and then count().
But you have done it beautifully simple and easy!!

Great!!
Thanks a lot for your help!!
N:B: Just look to my xls form… how I carried away in so complex!! :grinning_face_with_smiling_eyes: :grinning_face_with_smiling_eyes:

group_repeat_count.xlsx (12.3 KB)

2 Likes

@asif_rahman_joy

Wow :grin: it is indeed the same logic :slight_smile:

Glad this one helps.

Have a great year :innocent:

1 Like

@hakan_cetinkaya :clap: :heart:

1 Like

@hakan_cetinkaya

No way!! I am using your one… that is so cool!!

Thanks again!

Have a great year!! :+1: :+1: :+1:

2 Likes