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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

need help -cumulative sum for each month with no slicer

I am stuck in a situation. 
I have a revenue table connected to the calendar table by a date column. 

On the report page, I shouldn't have a date slicer.

I need to create a line chart, showing two lines, line1 cumulative sum for this month (i.e. from 01.02 to 16.02) and line2 shows cumulative sum for the same period last month ( i.e. 01.01 to 16.01). The x-axis should be Month-day-number (means from 1 to 31). 

 

I made the cumulative sum as follow: 

revenue-CM =
VAR MaxDate= TODAY()-1
VAR StartOfCurrentMonth = EOMONTH(TODAY()-1,-1) + 1
RETURN
CALCULATE(
SUM(revenue[revenue]),
'Calendar'[DateValue]<= MaxDate, 'Calendar'[DateValue]>=StartOfCurrentMonth)


Revenue-LM =
VAR StartOfPreviousMonth = EOMONTH(TODAY(),-2) + 1
VAR EndofPreviousMonth = EOMONTH(TODAY(),-1)
VAR CurrentDay= DAY(TODAY()-1)

RETURN (CALCULATE(SUM(Revenue[Revenue]),'Calendar'[MonthDayNumber]<=CurrentDay,'Calendar'[DateValue] >= StartOfPreviousMonth, 'Calendar'[DateValue]<= EndofPreviousMonth))
 
 
both of them are returning the final correct numbers. But they return the same number for each day.
image.png

 

can anybody help me? 

all the cumulative measures are with ALLSELECTED() function, or with MAX(DATE) , and they all work fine with a date filter (slicer).

1 ACCEPTED SOLUTION

@Anonymous , if you are using date from a date in visual you do not need a slicer, it should work 

 

you can try like

 

MTD QTY forced=
var _max = today()
return
if(max('Date'[Date])<=_max, calculate(Sum('order'[Qty]),DATESMTD('Date'[Date])), blank())
//or
//calculate(Sum('order'[Qty]),DATESMTD('Date'[Date]),filter('Date','Date'[Date]<=_max))
//calculate(TOTALMTD(Sum('order'[Qty]),'Date'[Date]),filter('Date','Date'[Date]<=_max))

 

LMTD QTY forced=
var _max = date(year(today()),month(today())-1,day(today()))
return
if(max('Date'[Date])<=_max, CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max), blank())
//OR
//CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)
//TOTALMTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)

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

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , with help from date table-use datesmtd

Revenue

MTD Sales = CALCULATE(SUM(Revenue[Revenue]),DATESMTD('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
Anonymous
Not applicable

@amitchandak 

Thank you or your answer. 

DATESMTD() works fine when there is a date filet on the page or on the visual. 

 

I need a formula which works without a date slicer. 

and the second point is that, with DATESMTD(), we can not have a cumulative sum from first day of last month to today's day at last month (today is 17.02, so to 17.01)

@Anonymous , if you are using date from a date in visual you do not need a slicer, it should work 

 

you can try like

 

MTD QTY forced=
var _max = today()
return
if(max('Date'[Date])<=_max, calculate(Sum('order'[Qty]),DATESMTD('Date'[Date])), blank())
//or
//calculate(Sum('order'[Qty]),DATESMTD('Date'[Date]),filter('Date','Date'[Date]<=_max))
//calculate(TOTALMTD(Sum('order'[Qty]),'Date'[Date]),filter('Date','Date'[Date]<=_max))

 

LMTD QTY forced=
var _max = date(year(today()),month(today())-1,day(today()))
return
if(max('Date'[Date])<=_max, CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max), blank())
//OR
//CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)
//TOTALMTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors
Top Kudoed Authors