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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
Anonymous
Not applicable

Unable to calculate MTD, YTD on Non-standard date table

We're using Non-standard date table in our project and i need help to calculate MTD, MTD LY, YTD, YTD LY, Yesterday, Yesterday LY, Today, Today LY, as my date table sample format is below with the start date and end date. I'm confused and stucked because time intelligence functions aren't working and I'm not getting the correct result.
In this date table, fiscal year starts from 7/3/22 and ends 7/1/23. I have already created a date table in power query editor.
Please help me.

Jaipal7494_0-1659450291450.png 

Jaipal7494_0-1659450634645.png

 

 

 

3 REPLIES 3
Anonymous
Not applicable

@amitchandak 

I have created Non standard date table with the help of below link

https://xcelanz.com/creating-a-4-4-5-calendar-with-power-query/

Anonymous
Not applicable

@amitchandak  
Thanks for you reply.
My calendar is a 445 calendar and I have created it, but I'm unable to calculate MTD, MTD LY, YTD, YTD LY, Yesterday, Yesterday LY, Today, Today LY. The fiscal year used to be April to March, but now because of management changes, it is starting on 3/7/22 and ending on 1/7/2023.

amitchandak
Super User
Super User

@Anonymous , Create a date table Using this table create the period and year in that

Power query wat to expand

https://amitchandak.medium.com/power-query-get-all-dates-between-the-start-and-end-date-9ad6a84cf5f2

 

or have column in calendar table already create

 

new column in date table

Period ID= maxx(filter(Period, Date[Date] >= period[Start Date] && Date[Date] <= period[End Date]), [Period ID])

Year = maxx(filter(Period, Date[Date] >= period[Start Date] && Date[Date] <= period[End Date]), [Year])

Period Start Date= maxx(filter(Period, Date[Date] >= period[Start Date] && Date[Date] <= period[End Date]), [Start Date])

 

Start Date Year = minx(filter( Date, [Year] = earlier([Year]) ), [Date])

 

Period Rank = RANKX(all(Period),Period[Period Start Date],,ASC,Dense)

Period Day = datediff([Period Start Date], [Date], day)

 

Day  of year = datediff([Start Date Year], [Date], day) Period Day = datediff([Period Start Date], [Date], day) 

Year Rank = RANKX(all('Date'),'Date'[Year Start date],,ASC,Dense)

 

 

Measure
This Period = CALCULATE(sum('Table'[Qty]), FILTER(ALL(Period),Period[Period Rank]=max(Period[Period Rank])))
Last Period = CALCULATE(sum('Table'[Qty]), FILTER(ALL(Period),Period[Period Rank]=max(Period[Period Rank])-1))

 


PTD = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Period Rank]=max('Date'[Period Rank]) && [Period Day] <=max([Period Day])))
LPTD = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Period Rank]=max('Date'[Period Rank])-1 && [Period Day] <=max([Period Day])))

 

This Year = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year Rank]=max('Date'[Year Rank])))
Last Year = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year Rank]=max('Date'[Year Rank])-1))

 

YTD= CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year Rank]=max('Date'[Year Rank]) && 'Date'[Day of Year] <= Max('Date'[Day of Year]) ))
LYTD = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year Rank]=max('Date'[Year Rank])-1 && 'Date'[Day of Year] <= Max('Date'[Day of Year])))

 

 

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

 

DAX Calendar - Standard Calendar, Non-Standard Calendar, 4-4-4 Calendar
https://www.youtube.com/watch?v=IsfCMzjKTQ0&t=145s

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.