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
carH
Helper I
Helper I

MTD Distinct Counts vs. Counts for the same MTD period for previous Years

Hi,

 

I finally found the following DAX to obtain Last Years MTD item count (vs. same # of days through the month TY). 

 

MTD LY Item Count = TOTALMTD(ItemPhase[Count Item],DATEADD(FILTER(DATESMTD('PBI dim_date'[Date]),'PBI dim_date'[Date]<TODAY()),-1,YEAR))
 
Here are my results. The MTD count for ActiveYear 2019 is correct (using the real data set). 

YearMonthNameActivateYearMTD Item Count
2018January201748
2019January2018122
2020January201916

 

What I really want is the MTD totals for 2020 and for 2018 (same # of days for the month as TY) as well. Is there a DAX calc that can provide this? My data set looks like this (although not complete).

 

ActiveYearActivateDateReformatItemNbr
20171/8/2017 0:0012345
20171/8/2017 0:0012346
20171/8/2017 0:0012347
20181/11/2018 0:0012348
20181/11/2018 0:0012349
20181/11/2018 0:0012350
20181/11/2018 0:0012351
20181/11/2018 0:0012352
20181/11/2018 0:0012353
20191/6/2019 0:0012354
20191/6/2019 0:0012355
20191/6/2019 0:0012356
20201/6/2020 0:0012357
20201/6/2020 0:0012358
20201/6/2020 0:0012359
20201/6/2020 0:0012360
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

did not get it completely. In the same formula you can change -1 values to go either side.

 

other ways you can use is

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
last year MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))

MTD (Year End) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFYEAR('Date'[Date])))
MTD (Last Year End) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFYEAR(dateadd('Date'[Date],-12,MONTH),"8/31")))

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-12,MONTH))  
Rolling last 12 before 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(dateadd('Date'[Date],-12,MONTH)),-12,MONTH))  

 

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

did not get it completely. In the same formula you can change -1 values to go either side.

 

other ways you can use is

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
last year MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))

MTD (Year End) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFYEAR('Date'[Date])))
MTD (Last Year End) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFYEAR(dateadd('Date'[Date],-12,MONTH),"8/31")))

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-12,MONTH))  
Rolling last 12 before 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(dateadd('Date'[Date],-12,MONTH)),-12,MONTH))  

 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.