# Cumulative Reporting

Hi all,

I would like to calculate a cumulative sum: cumulative total calculation involving summing values of the same data element form previous months with the data element value from the current month: For example, If the DE(X) value for January 2023 is 75 and the current DE(X) for February 2023 is 45, then the user should see sum is 120 for DE(X) in February; also if the DE(X) for March 2023 is 23 then the sum will be 120 (January and February) +23 (current value of March) = 143 and so on.

Can I do this kind of calculation in DHIS 2?

Thanks.

We use the Cumulative values tick box in Data Visualizer app to create graphs that do this. This results in a graph that is always increasing, for example:

3 Likes

Hi @fernando - there is some new functionality for calculating these types of cumulative indicators from 2.39. You can check the documentation here for Indicator year-to-date: Metadata - DHIS2 Documentation An expression to support your example: #{a}.yearToDate()

If you’re on an older version, in 2.36 you also have the possibility using periodOffset to achieve this. For example, if you want cumulative BCG doses from the last 11 months plus this month, you could do something like this in the numerator expression:
EPI - BCG doses given <1 year + EPI - BCG doses given <1 year.periodOffset(-1) + EPI - BCG doses given <1 year.periodOffset(-2) + EPI - BCG doses given <1 year.periodOffset(-3) + EPI - BCG doses given <1 year.periodOffset(-4) + EPI - BCG doses given <1 year.periodOffset(-5) + EPI - BCG doses given <1 year.periodOffset(-6) + EPI - BCG doses given <1 year.periodOffset(-7) + EPI - BCG doses given <1 year.periodOffset(-8) + EPI - BCG doses given <1 year.periodOffset(-9) + EPI - BCG doses given <1 year.periodOffset(-10) + EPI - BCG doses given <1 year.periodOffset(-11)

2 Likes

Hi @Rebecca,

I am using DHIS 2 version 2.36.12. Should this expression be put in the numerator in the aggregate indicator with indicator type - number (factor 1)?

Thanks

Yes, that’s how you can configure the indicator (with a 1 in the denominator). Note however, using the period offset is not a perfect solution for “year-to-date” cumulative values, since the expression doesn’t know how many months back the year begins. In this example it’s simply giving you the past 11 months + this month.