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! Learn more

Reply
Anonymous
Not applicable

How to make a date out of a string with YYYY - WW?

Hello,

 

I have a column with a year and week number (for example 2021 - 4) as a string. I want to use this (or a new one) for filtering and showing time-based results, so I have to make a date out of them. I found https://docs.microsoft.com/en-us/dax/date-function-dax online, but it doesn't discuss the week numbers. How do I handle weeks?

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Based on space I saw, suggesting, adjust a bit

 

Week to Date = var _st = date(left([Week],4),1,1)
var _week = right([Week],len(Week)- 6)*1
Return _st+((_week-1)*7) -WEEKDAY(_st,2)+1

 

Also, refer

 

Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123
https://www.youtube.com/watch?v=pnAesWxYgJ8

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous,

You can create a calendar table with date fields and year week number fields, then you can use this date field to link the fact table dates which you wanted to filter. After these steps, you can use the year week field as the source of slicer to filter records.
Regards,

Xiaoxin Sheng

amitchandak
Super User
Super User

@Anonymous , Based on space I saw, suggesting, adjust a bit

 

Week to Date = var _st = date(left([Week],4),1,1)
var _week = right([Week],len(Week)- 6)*1
Return _st+((_week-1)*7) -WEEKDAY(_st,2)+1

 

Also, refer

 

Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123
https://www.youtube.com/watch?v=pnAesWxYgJ8

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

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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