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
PVO1
Helper II
Helper II

Cumulative / running total start at Zero based on Calender slicer

Hello,

 

Currently I'm using the measure below to calculate my running total sales. This works fine, except;

I would like recalculate the running total for each slicer adjustment. At the moment it starts the total based on latest results, but I would like to start at 0.

 

For example:

No slicer adjustment (working as intended):

MonthWeekCumSales
11100
12200
13300
14400
21450
22500
23550
24600

 

Current results when slicing to month 2 (not intended)

MonthWeekCumSales
21450
22500
23550
24600

 

Desired result when slicing to month 2

MonthWeekCumSales
2150
22100
23150
24200

 

CumSales =
if(
  MIN(Cal[Date]) <= CALCULATE(MAX(Sal[Sales date]); all('Sal'));
    CALCULATE(SUM('Sal'[Sales])+0
      ;FILTER(ALL(Cal[Date]);Cal[Date] <= MAX(Cal[Date])))

 

 

1 ACCEPTED SOLUTION

I think I just found it!

 

CumSales =
if(
  MIN(Cal[Date]) <= CALCULATE(MAX(Sal[Sales date]); all('Sal'));
    CALCULATE(SUM('Sal'[Sales])+0
      ;FILTER(ALLSELECTED(Cal);Cal[Date] <= MAX(Cal[Date])))

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

Note quite following. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


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

Thanks for your feedback Greg. Tried to make it clearer with examples instead of text.

This challenge took my entire day 🙂

I think I just found it!

 

CumSales =
if(
  MIN(Cal[Date]) <= CALCULATE(MAX(Sal[Sales date]); all('Sal'));
    CALCULATE(SUM('Sal'[Sales])+0
      ;FILTER(ALLSELECTED(Cal);Cal[Date] <= MAX(Cal[Date])))

Offtopic comment, but you saved my day!!!

Thank you! 🙂

Hi @PVO1 

 

Glad that you've fixed it! please kindly mark it as the answer to help others find it more quickly. thanks!

 

 

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

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.