Calculating Program Indicators for events occurring in a specific period counting individuals

Hi DHIS2 Community,

We have a requirement to calculate the number of AGYW who received an HIV test in a specific period, regardless of when they are enrolled in the program (the requirement is for both quarterly and 6-monthly reports). I looked at the very useful ppt that @brian created here and my use case should meet slide 9 so I have set up a PI that uses Analysis type = Enrollment, Boundery:

Event date before end of period no offset or period type

Event date after start of period no offset or period type

Enrollment date before end of reporting period no offset or period type

Expression: V{enrollment_count}

Filter: (A{LVQ8iltuIlv} == ‘SD_HIGH’&& d2:hasValue(#{gwQ9ca8HETf.PstmAUUBl0A})
&& A{dIX2701I0OF} >= 15 && A{dIX2701I0OF} <= 24
&& A{fvvMhUJAnPR} == ‘SEX_FEMALE’
&& #{gwQ9ca8HETf.xOM4n1mMItH} == 1
&& #{nRdOU2BZfhw.JgAhHr3bOIk} ==1
&& (#{nRdOU2BZfhw.xgqGR3ROUnb} == 1 || #{nRdOU2BZfhw.QkcaVU9Pz5R} == ‘HIV_NEG’)
&& d2:hasValue(#{nRdOU2BZfhw.Ba5qdeGjlaW}) && (d2:hasValue(#{nRdOU2BZfhw.ra4zgpUlkW8})|| d2:hasValue(#{nRdOU2BZfhw.rY85XrVB9qY})))
||
(A{LVQ8iltuIlv} == ‘SD_MODERATE’ && (#{gwQ9ca8HETf.PstmAUUBl0A} == ‘RA_SEX_NON_REG’ || #{gwQ9ca8HETf.PstmAUUBl0A} == ‘RA_SEX_REG’ || #{gwQ9ca8HETf.PstmAUUBl0A} == ‘RA_SEX_SELL’)
&& A{dIX2701I0OF} >= 15 && A{dIX2701I0OF} <= 24
&& A{fvvMhUJAnPR} == ‘SEX_FEMALE’
&& #{gwQ9ca8HETf.xOM4n1mMItH} == 1
&& #{nRdOU2BZfhw.JgAhHr3bOIk} ==1
&& (#{nRdOU2BZfhw.xgqGR3ROUnb} == 1 || #{nRdOU2BZfhw.QkcaVU9Pz5R} == ‘HIV_NEG’)
&& d2:hasValue(#{nRdOU2BZfhw.Ba5qdeGjlaW}) && (d2:hasValue(#{nRdOU2BZfhw.ra4zgpUlkW8})|| d2:hasValue(#{nRdOU2BZfhw.rY85XrVB9qY})))

Filter:

The values are displaying, but it is displaying against the enrollment period because we are selecting analytics type = enrollment. So instead of showing report for e.g. Q3 2025 the values are split between Q2 and Q3 because some enrollments were in Q2. How do I get this to show in the period when the events occurred but still count only individual cases if there were more than 1 event for an enrollment within the period?

Hi Elmarie,

have you tried playing around with the following custom boundary type in the analytics period boundaries?
PS_EVENTDATE:nRdOU2BZfhw

This is just specifying the specific program stage event date.

best,
Yury

Hi Yury,

No we have not, I will try that and see if it makes a difference.

Also, maybe just remove the enrollment date boundary. It seems quite unlikely that you will have eventDates that will be earlier than the enrollment dates. (I do not know your use case, of course).

1 Like

@Elmarie_Claasen If the HIV test is recorded as an event and you want to count the number of AGYW who had that event in a specific period, then I think you might actually want to go for:

expression: V{tei_count}
Analytics type: Event (with the default period boundaries)

The event analytics type will make sure the calculation is only run on AGYW TEIs that have the HIV test event in the analytics period, and the TEI count expression will make sure each AGYW is only counted once, even if they have multiple HIV tests within the analytics period.

1 Like

If the AGYW only has a single enrollment, then V{enrollment_count} and V{tei_count} will give the same result, but I think V{tei_count} conveys the meaning of what you want more clearly.

2 Likes

Hi @plinnegan thanks I will explore this and revert back.

1 Like

Hi all,

Here is a slide deck in which I explain how we were troubleshooting this issue and actually found that there is another scenario for that one could add to the presentation @brian

1 Like

Hi @Elmarie_Claasen ,

Glad to hear the presentation was useful for you.

Your solution looks good, but just as an extra wrinkle to @plinnegan ‘s comment above:

the TEI count expression will make sure each AGYW is only counted once, even if they have multiple HIV tests within the analytics period.

With event type analytics, each AGYW will be counted only once per orgunit-period combination in your analytics query. The problem comes if an AGYW can receive a test from different orgunits within the same period. In that case, when you look at a “long” pivot table of tests per facility this month, the sum of that table may be larger than the result when you make a query at national level.

I have more such slides here , and go into more detail on aggregation challenges in the Tracker Analytics design guide.