Possible to create an indicator which counts '0' values

We have an Element for which some org units reported positive numbers and some reported 0, and some did not report. Now, we want to count how many reported ‘0’. We created an indicator with expression (element==0,1,0), but this does not return anything.

We tried other ways, like displaying the list of values in a pivot, which does not distinguish between 0 and ‘no value’. Not possible in DHIS2?

1 Like

Hi Mahmud,

I would use the filter expression :
d2:hasValue(‘varName’) && element == 0 for counting 0 values
d2:hasValue(‘varName’) && element > 0 for counting any positive non zero or empty values
! d2:hasValue(‘varName’) for empty values

The expression should be count(events or enrollments)

Good luck!

Sorry for not asking the question clearly first time, the indicator that we are trying to create is not Program indicator, rather normal. So d2 functions does not work.

Hi @Mahmud, at this time I believe the only way to accomplish what you want is using predictors. Create a predictor that has a generator expression like if(element==0,1,0). When you run the predictor, it will put a 1 or 0 into a new data element that you have created of 1 for each zero value it finds. (If your new data element says not to store zeros, then the zeros will not be stored.) Then, after the predictor has been run, you should be able to use an indicator to count the number of 1’s.