Analytics - indicators with null vs 0

Hi, I’m seeing some strange behaviour in analytics result with regards to «null» vs 0 results. This is in 2.24.

I have some indicators which are the sum of 1, 2 or more data elements. Zero is significant in this case, so zero value storage for data elements is enabled. For these indicators, I need to see:

  • if data elements being summed up are all blank, indicator should be blank

  • if at least one data element being summed is 0 and the others blank, indicator should be 0

  • if there are values > 0 being summed, indicator should be the sum

Now the part that is confusing me:

IF I make an analytics call with one orgunit, one indicator and several periods (all set as dimensions), this works as expected: periods where the indicator should be null is left out of the result, indicators that should be 0 or more are displayed correctly. HOWEVER, as soon as I include more orgunits or more indicators, and any of these have values in the period that was initially blank, the indicator value that was previously left out is suddenly included with value 0.0, so that it is not possible to differentiate between null and 0. HOWEVER, it looks like adding additional data elements does not have the same effect…

I’m not sure if the explanation make sense, but in short I need advice one how to query multiple orgunits and data items for multiple periods, and be able to differentiate blank and 0?

2 Likes

It happens also in 2.30 but when adding more Indicators instead orgUnits

1 Like

Hi, I think I am having the same issue in 2.41.
I have a simple Indicator which evaluates whether a Data element is 0 or greater 0 and then calculating the ratio. I understand that all blank fields should be excluded (Include zero values in Analytics tables in the System settings and show zero values for Data elements are selected). However, the indicator considers all blank fields as zero and shows a wrong ratio.
Is this a known issue? Is there a work around?
Thanks for your help,
George

1 Like

Hi, since the original issues was descibed, there is some new functionality with an isNotNull() function support, as well as the possibility of using subExpressions to count this before data is aggregated up: Metadata - DHIS2 Documentation

Some examples of how it can be used here: Analysis - DHIS2 Documentation

1 Like