Count Weeks in Sequential Year

Copper Contributor

I have been fighting with a formula for way too long and I hope you can help.

 

Our “gas-week” starts on a Friday and goes through Thursday. I want to assign a week number to each date. Seems easy enough with WEEKNUM (using 15-Friday as the first day of the week) or ISOWEEKNUM (but the default is week starts on Monday). The issue arises when the calendar flips.

 

The attached file shows a formula I believe is very close in column L  but it fails when the calendar flips to a year that starts on Friday (i.e. 2021).

 

Any guidance or help you can provide would be much appreciated – and probably put hair back in my head an years on my life.  Thanks!

7 Replies

@kcastrofan 

Perhaps

=MOD(ISOWEEKNUM(E4-WEEKDAY(E4,15))-1,52)+1

@Sergei Baklan 

 

It still gets confused in the second week of 2021. Expanded sample attached

 

DateDay of WeekWeek Num
1/1/2021Fri1
1/2/2021Sat1
1/3/2021Sun1
1/4/2021Mon1
1/5/2021Tue1
1/6/2021Wed1
1/7/2021Thu1
1/8/2021Fri1
1/9/2021Sat1
1/10/2021Sun1
1/11/2021Mon1
1/12/2021Tue1
1/13/2021Wed1
1/14/2021Thu1
1/15/2021Fri2
1/16/2021Sat2
1/17/2021Sun2

@kcastrofan 

Please check this update

=MOD(ISOWEEKNUM(E4-WEEKDAY(E4,15)),53)+(ISOWEEKNUM(DATE(YEAR(E4),1,1))=53)

@Sergei Baklan 

 

Tip of the cap to you sir! That worked perfectly.

@kcastrofan , great, glad it helped

@Sergei Baklan 

 

I apologize for the delayed follow up. But upon further inspection the formula mishandles years where week 53 starts on a Friday - the following partial week is assigned a week 52. It should be a continuation of week 53. Sample file is attached.

 

Thank you in advance for the follow up.

 

12/23/2016Fri52
12/24/2016Sat52
12/25/2016Sun52
12/26/2016Mon52
12/27/2016Tue52
12/28/2016Wed52
12/29/2016Thu52
12/30/2016Fri53
12/31/2016Sat53
1/1/2017Sun52
1/2/2017Mon52
1/3/2017Tue52
1/4/2017Wed52
1/5/2017Thu52
1/6/2017Fri1
1/7/2017Sat1
1/8/2017Sun1
1/9/2017Mon1
1/10/2017Tue1
1/11/2017Wed1
1/12/2017Thu1

@kcastrofan 

Perhaps I overcomplicated it, please check

=WEEKNUM(E4-WEEKDAY(E4,15)+1)

in attached.