dynamically calculate a power bi running total or cumulative total post image

Dynamically Calculate A Power BI Running Total Or Cumulative Total


The Power BI running total is the perfect way to display patterns and changes on a specified data over time.

In Power BI, there is a common combination of DAX functions that allow us to create a dynamic cumulative total (sum) on any report page.

The DAX formula that we’re about to discuss is easy to use and provides dynamic results. You can reuse the same formula combination. Just substitute different core measures or core calculations into it. This will enable you to generate cumulative totals (sums) over different calculations from a wide-scale to daily results. 

We’ll be using this Quarterly Insights report that I used during the Enterprise DNA Learning Summit last May 2018 as an example.  

sample report for calculating Power BI running total or cumulative total, power bi running total screenshot 1

Using The Date Table And Total Sales In Power BI

When running a cumulative total formula, we need to have a strong date table. This also goes for any time intelligence calculations.

Let’s drag these filters from the Quarterly Insights report to the sample report page. This way, we can drill into any time period.

filters from the Quarterly Insights report,  running total power bi screenshot 2

Then, let’s grab the Date field into the sample report page. This will serve as our date table.

Let’s also add the Total Sales column into the sample report page.

The Total Sales is considered as a simple core measure. This is because it’s easy to calculate. It can also be reused in various ways like Moving Averages or Running Totals.

Now, we need to utilize the correct combination of DAX formulas to get the cumulative total (sum).

Formula For Calculating The Cumulative Revenue

We’ll be using this formula as an example to calculate the Cumulative Revenue for the whole month of July in 2016.

Formula for calculating the  Power BI running total or cumulative total

As you can see here, we already have the Cumulative Revenue result that we want. Once we change the context, the cumulative sum also changes. This is what makes it dynamic.

 Column for the running total or cumulative total, cumulative total power bi screenshot 3

Let’s now try to analyze the given formula.

First, we’ll use the CALCULATE function to change the context of the calculation. Then, we’ll be including the Total Sales measure.

Using the CALCULATE Function for  the Power BI running total or cumulative total formula

As you can see here, the Total Sales for every single day was displayed.

Using The FILTER Function For Running Totals

Now, we’re going to use the FILTER function. This will adjust the context inside the CALCULATE function.

If we want to display the proper cumulative total, we need to manipulate the current context. This is for us to calculate not just one day, but all the days within that month as well.

As we go down the list, we need to create a wider time frame that we’re currently accumulating.

Every single row within the Cumulative Revenue column is being evaluated to a different context or filter that has been placed over the Sales table.

Using The ALLSELECTED Function For Running Totals

Furthermore, the ALLSELECTED function removes any or all the filters from the Date table that are placed within a certain context. In this case, the context is Q3 of 2016.

Using the ALLSELECTED Function for  the Power BI running total or cumulative total formula, cumulative sum power bi screenshot 4

Then, it reapplies those filters based on this logic.

To summarize, this part removes all filters over a 3-month window. Then, it iterates through every single one of those days to identify whether that date is less than or equal to the current max date.

Calculating The MAX Date

Let’s try to create a Max Date measure, then assign this logic to it.

This is what the MAX Date logic does.

MAX Date Column

As you can see, it evaluates to exactly the same day from the Date column.

Different Ways To Use The Power BI Running Total

Once you understand the logic for calculating running totals, it’ll be easier to use it in different ways.

For example, if we want to calculate the Cumulative Profits, we can still use the formula for the Cumulative Revenue. We just need to alter the formula a little bit.

Formula for calculating the  Power BI running total or cumulative total

We need to change the name of the measure to Cumulative Profits. Then, change the Total Sales to another core measure which is Total Profits.

Using this formula, we can also get the cumulative revenue of the last quarter. We’ll name this measure Cumulative Revenue LQ.

formula for calculating the Power BI running total or cumulative total of the last quarter

In this example, we just need to change the Total Sales to a time intelligence calculation like the Sales LQ.

Calculating The Revenue Difference Per Quarter

After having the Cumulative Revenue LQ measure, we can now get the difference between the revenue of the current quarter to that of the last quarter. The term for this technique is Measure Branching.

To do that, we need to create a new measure and name it Revenue Diff per Quarter. Then, we can subtract the Cumulative Revenue LQ from the Cumulative Revenue measure.

After successfully integrating the formula to the previously discussed measures (Cumulative Revenue LQ and Revenue Diff per Quarter), we can now display the visualizations for easier data analysis.

***** Related Links*****
Running Totals In Power BI: How To Calculate Using DAX Formula
Showcasing Budgets In Power BI – DAX Cumulative Totals
Cumulative Totals Based On Monthly Average Results In Power BI


The key point in this tutorial is understanding the formula and then tweaking it further to branch out to other measures.

Using a DAX formula allows you to show trends and provide a concrete comparison of measures over time.

By understanding the function of each section of the formula, you can obtain instantaneous results.

This changes how presentations are done. As long as you’re able to tweak the formula according to the information you require, your desired results will be shown straight away.

This is a good review of the technique for Power BI running total. I hope that you’ll be able to implement this in your own work.

For more DAX formula combination techniques, check out the Solving Analytical Scenarios module at Enterprise DNA Online. This course module covers all formulas that you can use to solve various analysis and insights in your reports.

Enjoy working through this detailed video.


Enterprise DNA Power BI On-Demand

13 comments on “Dynamically Calculate A Power BI Running Total Or Cumulative Total”

  1. Hello,

    I have a particular challenge that I am hoping can be addressed. I have been requested to do a cumulative sum of a cumulative measure. This is relatively easy to accomplish in Excel using absolute cell references (i.e. $C$2:C13).

    I can’t seem to figure out how to replicate this in Power BI. My measures are as follow:

    Est. Value = ‘Key Calc Measures'[Est. Gross Sales]*SUMX(‘Table’, ‘Table'[Service to Order Conversion])

    Cmltv. Est. Value = CALCULATE(‘Key Calc Measures'[Est. Value], Filter(ALLSELECTED(Date_Dim[FullDateAlternateKey]), Date_Dim[FullDateAlternateKey]<=MAX('Table'[Response Day])))

    I envisioned I would be able to do a calculation that iterated the Cmltv. Est. Value by date; therefore, allowing me to do a Cumulative OF the Cumulative. Perhaps I have been staring at this problem for too long and am missing an easy fix. Desired output below.

    Row Labels | Count |Cumulative Count | Cumulative SUM of Cumulative
    – SUM($B$2:B13) Count – SUM($C$2:C13)
    Jan 431 431 431
    Feb 589 1020 451
    Mar 752 1772 3223
    Apr 984 2756 5979
    May 304 3060 9039
    Jun 416 3476 12515
    Jul 843 4319 16834
    Aug 283 4602 21436
    Sep 470 5072 26508
    Oct 342 5414 31922
    Nov 892 6306 38228
    Dec 377 6683 44911

    The end goal is to provide an Estimated sales gain from a service performed. There is a weighting system in play, but that is built into the base measures.

    Any help would be appreciated

    1. Hi Trent,

      Thanks for your interest in Enterprise DNA Blogs.

      For calculating Cumulative of Cumulative Total, can try creating a formula like below. It is using Cumulative Total column and doing a further sumx. This is working with our sample data.

      Total of Cumulative Total = sumx(SUMMARIZE(filter(ALLSELECTED(Dates[Date]),Dates[Date] <= max(Dates[Date])),Dates[Date],"Cumm",[Cumulative Total]),[Cumm]) If still facing issues with the DAX, then raise a request at EDNA Forum https://forum.enterprisedna.co/ with sample PBIX and our team of experts will help you.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.