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
topazz11
Helper III
Helper III

Cumulative total by date

Hello,

 

I am trying to get two running totals as example below.

First one is for the toral up to yesterday (Today-1)

Second one is for the total on&after today. 

I tried these DAX...but doesnt work. 

 

Running total 1 :=
CALCULATE (
    [Total Sales],
    FILTER (
        ALL ( DimDate[Datekey] ),
        DimDate[Datekey] < Today( ( DimDate[Datekey] ) )
    )
)

 

Running total 2 :=
CALCULATE (
    [Total Sales],
    FILTER (
        ALL ( DimDate[Datekey] ),
        DimDate[Datekey] >= Today( ( DimDate[Datekey] ) )
    )
)

 

Any help would be greatly appreciated!

que2.JPG

 

2 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@topazz11 there are few ways to do this, here is one,  add following measures

 

Upto Today = CALCULATE( [Sum Item1], FILTER( 
   ALL( 'Date'[Date1] ),
    'Date'[Date1] <=  MAX( 'Date'[Date1] )) )
    * IF( MAX( 'Date'[Date1] ) < TODAY(), 1 )


From Today = CALCULATE( SUM( 'Table'[Item2] ), 
FILTER( ALL( 'Date'[Date1] ), 'Date'[Date1] <= MAX( 'Date'[Date1] ) && 
'Date'[Date1] >= TODAY() ))*
DIVIDE( [Sum Item2], [Sum Item2])

sum item1 and sum item 2 measures are just sum of respectice columns

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

Greg_Deckler
Super User
Super User

Have you tried the built-in running total quick measures? Also, See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ 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...

View solution in original post

3 REPLIES 3
Nira
New Member

How could this be achieved in POwer Query(performance will be affected)?  calculate the cumulative total for a Purchase Oder until it reaches its maximum date.
123  1.2.2022  5units   cumulative 5units
123  3.2.2022  2units   cumulative 7units
123  5.2.2022  6units     cumulative 13units

How could I achieve th ecumulative total in a column in POwer query?
Thank you

Greg_Deckler
Super User
Super User

Have you tried the built-in running total quick measures? Also, See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ 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...
parry2k
Super User
Super User

@topazz11 there are few ways to do this, here is one,  add following measures

 

Upto Today = CALCULATE( [Sum Item1], FILTER( 
   ALL( 'Date'[Date1] ),
    'Date'[Date1] <=  MAX( 'Date'[Date1] )) )
    * IF( MAX( 'Date'[Date1] ) < TODAY(), 1 )


From Today = CALCULATE( SUM( 'Table'[Item2] ), 
FILTER( ALL( 'Date'[Date1] ), 'Date'[Date1] <= MAX( 'Date'[Date1] ) && 
'Date'[Date1] >= TODAY() ))*
DIVIDE( [Sum Item2], [Sum Item2])

sum item1 and sum item 2 measures are just sum of respectice columns

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.