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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.