Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Russ
Helper I
Helper I

Problematic running total measure by transaction ID - slow and inconsistent.

Have a Power Bi model with two tables - Ledger and Dates - linked by date field.

 

Ledger contains the following fields, with data for several years.

 

Russ_0-1598363756497.png

 

I would like to produce a matrix with the following fields:

Ledger [TransID]

Dates [Date]

[Total Amount] - Measure

[Runtotal Amount By TransID] - Measure

 

I have the following two measures:

 

Total Amount = 
    SUM ( Ledger[Amount] )


Runtotal Amount By TransID =
CALCULATE (
    [Total Amount],
    ALL ( Dates[Date] ),
    FILTER ( ALL ( Ledger[TransID] ), Ledger[TransID] <= MAX ( Ledger[TransID] ) )

 

I would like the Runtotal to be by TransID and not date. Also, to be calculated over all time, hence All (Dates[Date]. The matrix will also be sliced by date and/or account, but this should have no affect on the RunTotal measure. 

 

The Runtotal measure seems to work ok on its own and also in a matrix alongside  Ledger [TransID] and [Total Amount]. This takes just over a second to compute.

 

However, as soon as I add the Dates [Date] field to the matrix the compute time runs into minutes. 

 

I'm hoping there is a better way of achieving my desired output. I have messed around with Summarize and AddCoulmns, but to no avail.

 

Any ideas?

 

 

 

 

 

 

3 REPLIES 3
v-lili6-msft
Community Support
Community Support

HI  @Russ 

You may try this formula as below:

Runtotal Amount By TransID = 
CALCULATE (
    [Total Amount],
    ALL ( Dates ),
    FILTER ( ALL ( Ledger[TransID] ), Ledger[TransID] <= MAX ( Ledger[TransID] ) ))

 

Use ALL ( Dates ) instead of ALL ( Dates[Date] )

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

@Russ - Maybe try:

Runtotal Amount By TransID =
CALCULATE (
    [Total Amount],
    FILTER ( ALL ( Ledger[TransID] ), Ledger[TransID] <= MAX ( Ledger[TransID] ) )

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  - thanks, but that does not fix it. Performance is exactly the same. Also, if you slice by date it makes the Runtotal incorrect.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.