How do I configure Indicator to show average value of a calculated DE percentage?

Let’s say I have the following data elements with aggregationType as SUM and the expected total value is 200. That is the sum cannot be greater than 200.

DE1 = 50
DE2 = 40
DE3 = 90

Mathematically if I want to express the average score as percentage I will do it like (DE1 + DE2 + DE3) / 200 * 100 = 90%. In this case there is no way the calculated value will be greater than 100.

In my indicator, I had done the following. Note that indicatorType is of factor 100 (percentage):

        {
            "annualized": false,
            "denominator": "200",
            "denominatorDescription": "200",
            "description": "Data Average",
            "id": "o6yEFrsybBH",
            "indicatorType": {
                "id": "hmSnCXmLYwt"
            },
            "name": "Data Average",
            "numerator": "#{DE1}+#{DE2}+#{DE3}",
            "numeratorDescription": "Sum of DEs",
            "shortName": "Data Average"
        }

But when I receive the data, some results are more than 100%.

Shouldn’t the formula be the sum of DEs in the numerator divided by the number of DEs?
(DE1 + DE2 + DE3…) / number of DEs
and then multiply by 100:
((DE1 + DE2 + DE3…) / number of DEs) * 100

If you want to restrict the sum of all DEs to not be greater than 200 then you’d probably need to use a program rule!

1 Like

@Gassim you know I am using a custom data capture app. When a user select an option for DE, the value of that option is hard-coded so each option has a maximum score. The sum of all the maximum score in my example above is 200. So if a user select a value in the DEs, they cannot exceed the maximum score.

So in my equation above,

Numerator = total score of selected options = (DE1 + DE2 + DE3) = 50 + 40 + 90 = 180
Denominator = total maximum score of all DEs = 200.

Say maximum score for DE1 = 50, DE2 = 50 and DE3 = 100. In this case DE1 score 50/50, DE2 score 40/50 and DE3 score 90/100.

So my equation seek to find the percentage of the selected score against the maximum score.

If I go by your suggestion, ((DE1 + DE2 + DE3…) / number of DEs) * 100 it will appear I am taking the average and not the percentage. Actually I have used my formula above in my existing project and it was working fine before I port to DHIS2.

In my case I don’t think I need to enforce the sum not to be greater than 200, because the users are selecting the options and the value for each options are sent to the server. There is no way a user can select a value more than the assign maximum score. So if you look at my indicator above, I assign 200 as the denominator because that is the maximum score that the sum of all DEs can attain even if the user select all the maximum option values.
Talking about program rule, do I need to enforce it for my scenario?

1 Like

On a closer look, I think the calculation works well at facility level. But when I try to get same at the highest OU hierarchy level, it is now giving me the total of all the percentage at facility level but what I want is average of all the percentage scores.

Is it possible to get the average of all the percentage score from the facilities from the visualizer app at the highest OU hierarchy level?

If you look at the first column in the image above, it is giving me the sum of the percentage score from each facility at the 2nd level of hierarchy where as I need the average of all the percentage scores.

Is it possible to get the average score from the result.

@Gassim My facilities OU are at level 5 and we receive the values as percentage from the indicators.

We want the average value of the percentages at OU level 2 and 1 which are higher levels. If I use the Option what I am getting is the sum of the percentage values at the higher OU levels.

Is there a way to get the average value? Or do I need to create another indicator from the existing indicators if possible?

Hi @jetisco4u

Thank you for your explanation!

What is the ‘aggregation type’ for the Data Elements you’re using in the indicator?

Sorry, since this is aggregate and not tracker then we can’t use program rules i.e. tracker program rules.


@jetisco4u
I think you might find this resource helpful:

Advanced aggregation settings (aggregation levels)

1 Like

It is sum.

Something I tried out was to create a new indicator to capture the average at the highest org unit level using the sum of all the DEs as numerator and the count of the organisationUnitGroup * max score as denominator. The result seems to come out well but I have not manually confirm if it is correct. However I would have prefer to just get the value using option tab in the app.

1 Like