YearWeeknum formula

Akakaboto

Board Regular
Joined
Jun 27, 2012
Messages
51
2016-02-21 00:00:00
2015-05-01 00:00:00

In my Powerpivot model I have a dimdate table with lots of different date formats. There is however one format missing that I would like to add as an extra column, namely YearWeeknum.


I want first to be written as "2015 w.08" and second as "2015 w.18"

So for all weeks<10 I want to add a "0" before the weeknumber to avoid having 2015 w.19, 2015 w.2, 2015 w.20, 2015 w.21....etc in my graphs.

=YEAR([FullDate])&" w."&WEEKNUM([FullDate];2) would work if i didn't care about the extra 0 for weeknum<10 but when I try to account for that the formula does not work, see below.

=YEAR([FullDate])&" w."&IF(WEEKNUM([FullDate];2)>10;"0"&WEEKNUM([FullDate];2);WEEKNUM([FullDate];2))

What is wrong in my formula above?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
=YEAR([FullDate])&" w."&IF(WEEKNUM([FullDate];2)>10;"0"&WEEKNUM([FullDate];2);WEEKNUM([FullDate];2))

Got this formula wrong when entering it here...but still not working

=YEAR([FullDate])&" w."&IF(WEEKNUM([FullDate];2)<10;"0"&WEEKNUM([FullDate];2);WEEKNUM([FullDate];2))
 
Upvote 0
I would use the FORMAT function to ensure the weeknum is always two digits.

This works for me:

=YEAR( [FullDate] ) & " w." & FORMAT( WEEKNUM( [FullDate]; 2 ); "00" )
 
Upvote 0
I would use the FORMAT function to ensure the weeknum is always two digits.

This works for me:

=YEAR( [FullDate] ) & " w." & FORMAT( WEEKNUM( [FullDate]; 2 ); "00" )

Thank you Ozeroth! It works perfectly. You just saved my day!
 
Upvote 0

Forum statistics

Threads
1,224,120
Messages
6,176,493
Members
452,732
Latest member
EWRUCK

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top