Countif Program rule function

Dear all,

I need help with a complicated program rule. I need DHIS2 to check whether 3 to 4 criteria are met and then count that as 1. This needs to happen across multiple sections within the event, with each section summed up to make a total.

I’ve been struggling to find a solution. I heard that d2:condition might work, but it’s not available on the DHIS2 instance I’m using (version 2.41.5.1).

I’ve also tried implementing this with program indicators, but there’s no way to sum the indicators except by using Data Visualizer, which isn’t what I want.

An example of the criteria. Countif( Gestational age is < 12, Anemia test = “PCV” , Anemia test result is >= 30, Anemia test result is <= 33)

1 Like

Hi @Mr_jorge one idea that comes to mind is to count each criteria individually, add them together, and then check if the sum is greater than the necessary threshold.

So assuming that you are checking whether at least 3 criteria are met, the formula could look like:
IF(
(
IF(Gestational age is < 12, 1, 0) +
IF(Anemia test = “PCV”, 1, 0) +
IF(Anemia test result >= 30, 1, 0) +
IF(Anemia test result <= 33, 1, 0)
) >= 3, 1, 0)

I hope this helps

2 Likes