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

I need to get the Max Week number which is having the data using Calendar Table

Hi All,

         I am using Date table to get last 4 weeks data for that i have used below calculated columns.

Weeks = DATEDIFF(TODAY(),Dim_MasterCalendar[Date],WEEK)
Last 4 Weeks = IF(Dim_MasterCalendar[Weeks]>=-3 && Dim_MasterCalendar[Weeks]<=0, "Last 4 Weeks")
here i am having the data upto 33 week but the current week is 37. when i select last 4 weeks filter its not showing any data hence data is not present, look at the below visual.
1.png
So my requirement is to get the data from 33 week to last 4 weeks which is having the data. please suggest me a way to get this requirement. 
 
1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Hello @Anonymous 

One thing you could do is instead of using TODAY() you could use the highest date in your detail table.

Weeks = DATEDIFF( MAX ( YourTable[Date] ) ,Dim_MasterCalendar[Date],WEEK

That way week 0 would be the oldest week where you have detail rather than the week of today.

View solution in original post

1 REPLY 1
jdbuchanan71
Super User
Super User

Hello @Anonymous 

One thing you could do is instead of using TODAY() you could use the highest date in your detail table.

Weeks = DATEDIFF( MAX ( YourTable[Date] ) ,Dim_MasterCalendar[Date],WEEK

That way week 0 would be the oldest week where you have detail rather than the week of today.

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.