Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hello,
I have a DateKey table shown below that I'd like to connect to a table that shows weekly inventory levels. I need to create a one-to-many relationship between the two tables, but am unable to do so (cannot join on week number because the DateKey table has multiple entries for each week).
Any ideas how to get around this?
Thank you!
DateKey
Weekly inventory table
Solved! Go to Solution.
Assuming a couple of items
Give this measure a try as a calculated column in your week inventory table.
Date of Week = VAR YearStart = DATE(VALUE(LEFT('Weekly Inventory'[WeekNum],4)),1,1) VAR YearStartDay = WEEKDAY(YearStart,2) VAR WeekStartDate = YearStart + VALUE(RIGHT('Weekly Inventory'[WeekNum],LEN('Weekly Inventory'[WeekNum])-4)) * 7 - 7 - (YearStartDay-1) RETURN MAX(YearStart,WeekStartDate)
Here is how the table looks in my test. Each year starts on the 1st but after that all weeks start on the Monday.
On your weekly inventory table add a column for [Week Date] which would be the date of the first day of that week. 1/1/2019 for wk1-2019, 1/8/2019 for wk2-2019 etc. The you can join the [Week Date] column to your date table.
Is there a convenient way to do this in Power BI?
Assuming a couple of items
Give this measure a try as a calculated column in your week inventory table.
Date of Week = VAR YearStart = DATE(VALUE(LEFT('Weekly Inventory'[WeekNum],4)),1,1) VAR YearStartDay = WEEKDAY(YearStart,2) VAR WeekStartDate = YearStart + VALUE(RIGHT('Weekly Inventory'[WeekNum],LEN('Weekly Inventory'[WeekNum])-4)) * 7 - 7 - (YearStartDay-1) RETURN MAX(YearStart,WeekStartDate)
Here is how the table looks in my test. Each year starts on the 1st but after that all weeks start on the Monday.