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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
prasy14
Helper I
Helper I

Last Year MTD/QTD/YTD with dynamic end date

I have DAX Calculation MTD,LYMTD,QTD,LYQTD etc, The Sales table has Sales Date and it has relationship with Time Dimension table(Time'[PK_Date]). The issue is the data in Sales table based on Daily refresh. so, Sales Table will have data till yesterday if i refresh data today. 

 

FYI, I have 'Time'[PK_date] slicer so, that users can select the date and all calculation will be based on that date.

 

According to my calculation below. MTD will be calculated from 1st of Month till Today(), but as i have data till yesterday in my system. So, data calculation for MTD is 1st of month till yesterday as there is no data of today in system. whereas my LYMTD is calculating till Today's date of last year but i want to calculate it by yesterday or Max date in sales table. how can i calculate LYMTD by max date in sale table date.

 

 

MTD = TOTALMTD(SUM(Sales[ Billed Sales]),'Time'[PK_Date])

LYMTD = TOTALMTD(SUM(Sales[Billed Sales]),SAMEPERIODLASTYEAR(DATESMTD('Time'[PK_Date])))

QTD = TOTALQTD(SUM(Sales[Billed Sales]),'Time'[PK_Date])

LYQTD = TOTALQTD(SUM(Sales[Billed Sales]),SAMEPERIODLASTYEAR(DATESQTD('Time'[PK_Date])))

4 REPLIES 4
parry2k
Super User
Super User

may be reduce one day for last period date something like this.

 

LYMTD = TOTALMTD(SUM(Sales[Billed Sales]),SAMEPERIODLASTYEAR(DATESMTD(DATEADD('Time'[PK_Date]),-1,DAY))))

 



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.

Hi Parry2k ,

 

it not always one day... that is reason i want to do it by max date in sales table.

in my opinion that doesn't make sense, if you are doing MTD, regardless how the weekdays are, you are always counting 1st of every month until some day of the month regardless previous month/quarter falls on weekend.

 

May be your queston is bit different than MTD?



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.

Yes, I am always counting 1 st every month and End date should be dynamic. Yes, i agree it does not depend on weekday or weekend,disregard my above example...the only point is it not always one day.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.