DAX Power BI: CALCULATE — Calculation of the cumulative sales total

Andrei Khaidarov, Microsoft MVP, PhD
Microsoft Power BI
Published in
2 min readSep 20, 2023

--

This article will break down the calculation of the cumulative total by order number.

Our initial table:

Use the measure to calculate the amount of accepted orders

Let’s calculate a new measure and create a table for it. If we display this measure in the summary table by placing the [Order ID] column first and dragging our measure into it, we will see the cumulative total of sales. Let’s drag the [Status], [Total] columns and the TotalSum and CumulativeTotalByOrderNum measures into the summary table for ease of understanding

It turns out that orders from the first to the fifth were canceled and we do not calculate them. Further, the sixth order was sold for 41200 and the sum of 41200 was accumulated. The seventh order we have 8700 and the accumulated amount is 49900 (41200+8700). The eighth bid is canceled and so on.

We transfer the measure to Power BI for clarity in the form of a graph.

We get a graph of accumulated payments, but if we want to filter by product name, the graph won’t be quite right.

This is due to the fact that in our measure we have removed all filters using ALL.

To fix the situation, the ALL function should be replaced by ALLSELECTED, now the chart is filtered as needed for a specific product.

Don’t forget to subscribe to

👉 Power BI Publication

👉 Power BI Newsletter

and join our Power BI community

👉 Power BI Masterclass

--

--

Andrei Khaidarov, Microsoft MVP, PhD
Microsoft Power BI

🎓 Microsoft Data Platform MVP | MCT | Power BI Super User | Global Power Platform Hero| Power Platform Solution Architect| Technical reviewer for Packt's books