Program indicator to count number of stages for a TEI

Hi all,
Does anyone have tips on how I might create a program indicator to count the number of TEIs who have experienced a certain number of stages? Like count all TEIs who have more than two stages, or certain stages. Right now I have chosen a data element in each stage that would definitely be filled out, and used d2:hasValue. Wondering if there is a better way though, even to get a count of the number of stages for each TEI (count those with 1 stage only, 2 stages, 3…)
If you wanted to count stages across programs (if the TEI is enrolled in multiple programs), you could create a regular indicator and add up the program indicators for each program - but then you would double count some TEIs, right?


Hi @Natalie_Tibbels
You might get a smaller expression if you use the d2:zpvc() function, otherwise it seems like you found the on of the few way of doing this sort of calculation at the moment - namely base it on the presence of data values from the different stages.

It is maybe worth noting that you with this strategy you will not be able to compare program stages across multiple enrollments for one TEI. This might not be a problem in your case if the enrollments is separated in time, or if the TEI only has one enrollment.

It is not presently possible to make an indicator that does the comparison across several programs for one TEI. We have a jira epic where this query that covers comparing several enrollments/program for one TEI:


Hi all, follow up question -
I am looking for help developing indicators for a tracker program that help us see the “dose” of the program received. I know that there’s not an easy way to visualize (in event reports for dashboards) data elements from multiple program stages at the same time, because event reports does not allow you to combine DEs from different stages. [this would be a cool feature though] You can use indicators, but…
We have enrollment followed by 4 different follow up stages. I want to know how many TEIs received 1, 2, 3, or 4 follow ups. I have indicators to count enrollments using d2:hasValue for a compulsory data element in each stage to see the total who experienced each stage. But this does not tell me how many TEIs ONLY received one follow up for example - because I would have to have a way to say that certain stages do not exist or that certain compulsory DEs do not have a value. Is there a function that could work to exclude TEIs from the count when certain stages are not used?
Thanks for any ideas.

1 Like


I try to do the same thing but I don’t know how to do.

I have a programme with a lot of stages and I would like to have an allert when an entity get 3 stages and more.

I think I need to configure an indicator or a program indicator but I don’t know how to verify this condition for every entity.

The stages can be duplicated for one entity.

Every entity are enrolled only in one program.

Is someone can help me ?


Hello, bumping this back up to see if others have made progress on counting the number of stages for a TEI. In my current dilemma, I have one tracker program with 3 separate stages that count attendance at a session. Then a fourth repeatable stage that counts referrals. I want a program indicator that counts the number of sessions the participant has attended. Right now I have an event count, and the filter is a compulsory yes/no data element in each of the session stages.

Expression: V{event_count}
Filter: #{attended session 1} == 1 || #{attended session 2} == 1 || #{attended session 3} == 1

But the indicator is counting the fourth referral stage that does not include any of those data elements and I can’t figure out how to exclude that stage from the event count.


Hi Natalie,

In your filter could you not filter out by Program stage ID?
So you could have an addition to the filter of:
&& V{program_stage_id} != ‘ID of repeatable stage’



Thank you! I was not aware of that option and seems like it should work great! I tested it though and it’s still counting all the events. See screenshots. It actually seems like the program stage ID may not be working at all in the filter? because the “test” indicator I have only filters for the program stage ID and it’s having no effect. Will keep trying and see if I can figure out it out and update.
Screen Shot 2021-02-11 at 7.43.14 PM

Hi Natalie,

Thanks for the feedback, I’ll see if I can test as well and I’ll get back to you if I pick anything up.