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