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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
michellepace
Resolver III
Resolver III

"Sales Running Total"... start date not being adhered to

 Hi there,

 

The Problem: I am busy learning DAX. I worked through this Cummulative Total DAX PATTERN article. Whilst it works fine provided I select the initial date in my dataset... if I select anything later (such as 02/01/2018) the values before this date are still summed up. 

 

My Question: How do I modify this code such that the start date is adhered to? I attempted to add a second condition Dates[Date]>=FirstVisibleDate in the second argument of Calculate, but that really didn't work as intended.

 

a.png

Many thanks,

Michelle

1 ACCEPTED SOLUTION

@michellepace - The standard Running Total quick measure works great. See attached PBIX, Table (13), Page 13.

SALES running total in DATE = 
CALCULATE(
	SUM('Table (13)'[SALES]),
	FILTER(
		ALLSELECTED('Table (13)'[DATE]),
		ISONORAFTER('Table (13)'[DATE], MAX('Table (13)'[DATE]), DESC)
	)
)

 



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

8 REPLIES 8
amitchandak
Super User
Super User

@michellepace , try like

Cumm Sales = CALCULATE(max(Sales[Purchase Date]),filter(date,date[date] <=maxx(date,date[date])))

or

Cumm Sales = CALCULATE(SUM(Sales[Purchase Date]),filter(allselected(date),date[date] <=maxx(date,date[date])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak , thank you for your reply. I have that solution too. However, I am trying to learn dax. And I am trying to figure out how one could modify the equation given by DAX PATTERNS above such that the cumulative total begins at the minimum selected dated. Any ideas or is ti completely not possible? 

@michellepace - The standard Running Total quick measure works great. See attached PBIX, Table (13), Page 13.

SALES running total in DATE = 
CALCULATE(
	SUM('Table (13)'[SALES]),
	FILTER(
		ALLSELECTED('Table (13)'[DATE]),
		ISONORAFTER('Table (13)'[DATE], MAX('Table (13)'[DATE]), DESC)
	)
)

 



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@michellepace - Also works with separate Calendar table:

SALES running total in Date 2 = 
CALCULATE(
	SUM('Table (13)'[SALES]),
	FILTER(
		ALLSELECTED('Calendar'[Date]),
		ISONORAFTER('Calendar'[Date], MAX('Calendar'[Date]), DESC)
	)
)


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thank you Greg.

@michellepace  - just a suggestion, but the pages of the DAX Patterns have a comment section and the authors actively respond to questions specifically for their patterns.

 

Hope this helps,

David

Greg_Deckler
Community Champion
Community Champion

@michellepace - Can you post sample data as text so that I can recreate? 

Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, 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

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

> 1. Sample data as text, use the table tool in the editing bar
DATE|SALES
01/01/2018|60507
02/01/2018|69471
03/01/2018|100845

 

> 2. Expected output from sample data
a.png

> 3. Explanation in words of how to get from 1. to 2.
Whilst it works fine provided I select the initial date in my dataset... if I select anything later (such as 02/01/2018) the values before this date are still summed up. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.