Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi all,
I have got a specific question about calculating a running total. I've reviewed the other messages about this subject but couldn't find a solution to my problem.
Please review below table called "data".
As you can see this table has a column called "Posting date" of the Date type. Therefore I have also added a date table called "calendar" and created a relationship between 'data'[Posting date] and 'calendar'[DateKey].
In order to calculate the global amount I've created a measure called "AmntGlobal". The DAX formula is:
AmntGlobal := CALCULATE ( SUM ( data[Amount] ), FILTER ( data, data[Currency Type] = "20" ) )
This is the output of "AmntGlobal":
Now I want to create a running total of "AmntGlobal" called "RT AmntGlobal". I have two options to do this.
RT AmntGlobal1 :=
IF (
COUNTROWS ( data ) <> 0,
CALCULATE (
[AmntGlobal],
FILTER ( ALL ( calendar ), calendar[DateKey] <= MAX ( calendar[DateKey] ) )
)
)RT AmntGlobal2 :=
IF (
COUNTROWS ( data ) <> 0,
CALCULATE (
SUM ( data[Amount] ),
FILTER ( data, data[Currency Type] = "20" ),
FILTER ( ALL ( calendar ), calendar[DateKey] <= MAX ( calendar[DateKey] ) )
)
)I can't figure out why the "stand-alone" method doesn't work. I know that consecutive filter statements work as an AND statement, giving the intersection of the statements as the combined result. I just can't figure out why the placement of filter statements (both in one formula vs one in each) can have this effect.
Can you please provide insight?
Many thanks in advance!
Rg. Erwin
In this scenario, when you reference a measure in CALCULATE(), the filter in that measure is applied on that entire specified table. So if you want to include those filter together into same CALCULATE(), you need to add ALL() on data table.
Regards,
Just to see if I understand this correctly, what you're saying is that, while my original formula for AmntGlobal2 was:
RT AmntGlobal2:=IF (
COUNTROWS ( data ) <> 0,
CALCULATE (
SUM ( data[Amount] ),
FILTER ( data, data[Currency Type] = "20" ),
FILTER ( ALL ( calendar ), calendar[DateKey] <= MAX ( calendar[DateKey] ) )
)
)
It should actually have been:
RT AmntGlobal2:=IF (
COUNTROWS ( data ) <> 0,
CALCULATE (
SUM ( data[Amount] ),
FILTER ( ALL ( data[Currency Type]), data[Currency Type] = "20" ),
FILTER ( ALL ( calendar ), calendar[DateKey] <= MAX ( calendar[DateKey] ) )
)
)
First of all, this new filter on currency type solves the running total issue. The problem is that I still don't understand how this works. Let me explain.
If you recall, the problem with AmntGlobal2 was that it didn't calculate a running total amount, not that it didn't filter on currency type (this it did correctly). So I don't understand why a correction of the filter on currency type suddenly solves the running total problem.
Can you eleborate on this?
Rg. Erwin
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 40 | |
| 35 | |
| 34 | |
| 31 | |
| 28 |
| User | Count |
|---|---|
| 136 | |
| 102 | |
| 68 | |
| 66 | |
| 58 |