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
Anonymous
Not applicable

DAX ADD COLUMNS

have several time-based metrics such as MTD (Month-to-Date), YTD (Year-to-Date), and QTD (Quarter-to-Date). For the MTD calculation, I want it to show data from the 1st to the last day of the previous month if the current date is the 1st day of a new year. AND TODAY -1 FOR EACH  Similarly, for QTD, I need it to display data from the start of the previous quarter until December 31st if a new quarter starts. OR normaly when new quater starts need to show previous quater , Additionally, for YTD, when it's January 1st of a new year, I'd like it to show data from January 1st of the previous year to December 31st of the previous year.

Could you please assist me in rewriting the logic for this calculated column?

Thank you very much for your help!

 

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous, Ideally you should use TI and create measures.


Here are some flags for Date Table

Addcolumns( <Table code> ,

"MTD", if([Date]<= today() && [Date] >= eomonth(today(), -1)+1, "MTD" )
"LMTD", if([Date]<= date(year(today()), month(today())-1, day(today())) && [Date] >= eomonth([Date], -2)+1, "LMTD" )
"QTD", var _max = today()
var _min = eomonth(_max,-1* if( mod(Month(_max),3) =0,3,mod(Month(_max),3)))+1
return
return
if([Date]<= _max && [Date] >= _min, "QTD" )
"LQTD" ,var _max = Date(year(today()), Month(Today())-3, day(today()))
var _min = eomonth(_max,-1* if( mod(Month(_max),3) =0,3,mod(Month(_max),3)))+1
if([Date]<= _max && [Date] >= _min, "LQTD" )
"YTD", if([Date]<= today() && [Date] >= eomonth(today(), -1* month(today()) )+1, "YTD" ) )

 

 

for TI

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

 

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

Top Solution Authors