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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
icdns
Post Patron
Post Patron

Convert Week No to Date Range

Hello, 

 

Would like to ask for your help. I wanted to convert my Week No into Date Range, for example: 

Week 46 = 11/10/2019 - 11/16/2019 (Start on a Sunday to Saturday) 

 

I have created a dimension table for dates, an I am using Week of Year for my "Week No: 

icdns_0-1595324940828.png

 

I have tried creating some columns but it's not working 😞

 

Can someone help me out? Thank you so much!

 

- IC 

 

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @icdns 

 

Based on your description, I created data to reproduce your scenario.

Calendar(a calculated table):

Calendar = CALENDAR(DATE(2019,1,1),DATE(2020,12,31))

 

Calculated column:

Year = YEAR('Calendar'[Date])
Week of Year = WEEKNUM('Calendar'[Date])

 

You may create a calculated column or a measure as below.

Calculated column:
Date Range column = 
var _mindate = 
CALCULATE(
    MIN('Calendar'[Date]),
    FILTER(
        ALL('Calendar'),
        'Calendar'[Year]=EARLIER('Calendar'[Year])&&
        'Calendar'[Week of Year]=EARLIER('Calendar'[Week of Year])
    )
)
var _maxdate = 
CALCULATE(
    MAX('Calendar'[Date]),
    FILTER(
        ALL('Calendar'),
        'Calendar'[Year]=EARLIER('Calendar'[Year])&&
        'Calendar'[Week of Year]=EARLIER('Calendar'[Week of Year])
    )
)
return
_mindate&" - "&_maxdate

Measure:
Date Range measure = 
var _mindate = 
CALCULATE(
    MIN('Calendar'[Date]),
    FILTER(
        ALL('Calendar'),
        'Calendar'[Year]=SELECTEDVALUE('Calendar'[Year])&&
        'Calendar'[Week of Year]=SELECTEDVALUE('Calendar'[Week of Year])
    )
)
var _maxdate = 
CALCULATE(
    MAX('Calendar'[Date]),
    FILTER(
        ALL('Calendar'),
        'Calendar'[Year]=SELECTEDVALUE('Calendar'[Year])&&
        'Calendar'[Week of Year]=SELECTEDVALUE('Calendar'[Week of Year])
    )
)
return
_mindate&" - "&_maxdate

 

Result:

a1.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @icdns 

 

Based on your description, I created data to reproduce your scenario.

Calendar(a calculated table):

Calendar = CALENDAR(DATE(2019,1,1),DATE(2020,12,31))

 

Calculated column:

Year = YEAR('Calendar'[Date])
Week of Year = WEEKNUM('Calendar'[Date])

 

You may create a calculated column or a measure as below.

Calculated column:
Date Range column = 
var _mindate = 
CALCULATE(
    MIN('Calendar'[Date]),
    FILTER(
        ALL('Calendar'),
        'Calendar'[Year]=EARLIER('Calendar'[Year])&&
        'Calendar'[Week of Year]=EARLIER('Calendar'[Week of Year])
    )
)
var _maxdate = 
CALCULATE(
    MAX('Calendar'[Date]),
    FILTER(
        ALL('Calendar'),
        'Calendar'[Year]=EARLIER('Calendar'[Year])&&
        'Calendar'[Week of Year]=EARLIER('Calendar'[Week of Year])
    )
)
return
_mindate&" - "&_maxdate

Measure:
Date Range measure = 
var _mindate = 
CALCULATE(
    MIN('Calendar'[Date]),
    FILTER(
        ALL('Calendar'),
        'Calendar'[Year]=SELECTEDVALUE('Calendar'[Year])&&
        'Calendar'[Week of Year]=SELECTEDVALUE('Calendar'[Week of Year])
    )
)
var _maxdate = 
CALCULATE(
    MAX('Calendar'[Date]),
    FILTER(
        ALL('Calendar'),
        'Calendar'[Year]=SELECTEDVALUE('Calendar'[Year])&&
        'Calendar'[Week of Year]=SELECTEDVALUE('Calendar'[Week of Year])
    )
)
return
_mindate&" - "&_maxdate

 

Result:

a1.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

mahoneypat
Microsoft Employee
Microsoft Employee

On your Date table, you can add a YearWeek column with

YearWeek = YEAR('Date'[Date]) & WEEKNUM('Date'[Date])
 
And then add your Week Range column with this expression
 

 

Week Range =
VAR thisweekmin =
    CALCULATE ( MIN ( 'Date'[Date] ), ALLEXCEPT ( 'Date', 'Date'[YearWeek] ) )
VAR thisweekmax =
    CALCULATE ( MAX ( 'Date'[Date] ), ALLEXCEPT ( 'Date', 'Date'[YearWeek] ) )
RETURN
    FORMAT (
        thisweekmin,
        "mm/dd/yyyy" & "-"
            & FORMAT ( thisweekmax, "mm/dd/yyyy" )
    )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


amitchandak
Super User
Super User

@icdns , depend on week start Sunday - 1 and Monday - 2 in week day

 

New column but it need year column too

Week to Date = var _st =Date( [Year],1,1)
var _week = right([Week],2)*1
Return _st+((_week-1)*7) -WEEKDAY(_st,2)+1

 

Also disucssed in my blog : https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3

 

 

 

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

Hi!

 

Thank you for your prompt feedback! However, how can I convert it into: 

 

11/10/2019 - 10/16/2019 format? instead of just one date. 

 

Thanks in advance! 🙂 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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
Top Kudoed Authors