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
Justas4478
Post Patron
Post Patron

Category with specific dates

Hello I am trying to create a measure that checks weeks left to refresh for specific category in Level5 column. This is the table.Table.png 

This is Weeks to refresh measure. Measure.png 

I am trying to modify measure since it needs to have specific refresh date for each Level 5 category. For level 5 categories that are in the table refresh dates are Female = 2022/06/20, Open = 2022/07/25, Wedding = 2022/03/28. At the moment Weeks to Refresh measure is just for one date and nor categories specific. Idea for measure is something like this. DATEDIFF(IF(Level 5 = Open,(today()-1, date(2022,07,25),WEEK),IF(Level 5 = Female,(today()-1, date(2022,06,20),WEEK),IF(Level 5 = Wedding,(today()-1, date(2022,03,28),WEEK). Expected results Female = 13 weeks, Open = 18 weeks, Wedding = 1 week. 

 

Let me know if there is need for any additional information. Thanks.

 

1 ACCEPTED SOLUTION

Ah, OK. Try something like

Weeks to refresh =
var currentCategory = SELECTEDVALUE('Table'[Category 5])
var refreshDate = SWITCH( currentCategory,
   "Open", DATE(2022, 7, 25),
   "Female", DATE(2022, 6, 20)
)
return DATEDIFF( TODAY()-1, refreshDate, WEEK)

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

Create a new table with the Category and the refresh date. You can then use RELATED or LOOKUPVALUE to get the target refresh date and do a datediff with today

Due to Live connection method I am only able to use measures. I cant use calculated columns or create tables.

Ah, OK. Try something like

Weeks to refresh =
var currentCategory = SELECTEDVALUE('Table'[Category 5])
var refreshDate = SWITCH( currentCategory,
   "Open", DATE(2022, 7, 25),
   "Female", DATE(2022, 6, 20)
)
return DATEDIFF( TODAY()-1, refreshDate, WEEK)

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.