Custom columns in power query - Adding text to the weekofyear value

sadavies2906

New Member
Joined
Feb 5, 2011
Messages
45
I have created a custom column in a power query that returns the week number of a list of start dates using the following

=Date.WeekOfYear([Start Date])

Below is the output I get in the column header "WEEK", I want to get an output that looks like the column header "EXPECTED".

Not only do I need to add the text "Week" in front of the result but I also need the output to use the current day and work out if the start date is in the past with regards the week number and change those to the text "BACKLOG"

So if I opened the file today on the 20/02 which is week 8, all start dates prior to this week would return "BACKLOG", any start dates in this week would return "Week 8" and anything in the future would have its correct week number.

Hope I've explained this ok

Start DateWeekExpected
01-Apr14Week 14
02-Mar10Week 10
30-Jan5BACKLOG
23-Feb8Week 8
22-Feb8Week 8
17-Feb8Week 8
14-Feb7BACKLOG
20-Feb8Week 8
10-Jan2BACKLOG
15-Jan3BACKLOG
02-Feb5BACKLOG
 
Book1
ABC
1Need DateWeekNew Week
217/09/2020Week 38Week 41
317/09/2020Week 38Week 41
418/09/2020Week 38Week 41
525/09/2020Week 39Week 41
629/09/2020Week 40Week 41
730/09/2020Week 40Week 41
830/09/2020Week 40Week 41
901/10/2020Week 40Week 41
1002/10/2020Week 40Week 41
1102/10/2020Week 40Week 41
1202/10/2020Week 40Week 41
1302/10/2020Week 40Week 41
1402/10/2020Week 40Week 41
1505/10/2020Week 41Week 41
1606/10/2020Week 41Week 41
1707/10/2020Week 41Week 41
1813/10/2020Week 42Week 42
1914/10/2020Week 42Week 42
2015/10/2020Week 42Week 42
2119/10/2020Week 43Week 43
2219/10/2020Week 43Week 43
2321/10/2020Week 43Week 43
2426/10/2020Week 44Week 44
2527/10/2020Week 44Week 44
2627/10/2020Week 44Week 44
2705/11/2020Week 45Week 45
2805/11/2020Week 45Week 45
2906/11/2020Week 45Week 45
3009/11/2020Week 46Week 46
3109/11/2020Week 46Week 46
3209/11/2020Week 46Week 46
3316/11/2020Week 47Week 47
3417/11/2020Week 47Week 47
3517/11/2020Week 47Week 47
3623/11/2020Week 48Week 48
3723/11/2020Week 48Week 48
3824/11/2020Week 48Week 48
3902/12/2020Week 49Week 49
4002/12/2020Week 49Week 49
4102/12/2020Week 49Week 49
4207/12/2020Week 50Week 50
4307/12/2020Week 50Week 50
4407/12/2020Week 50Week 50
4514/12/2020Week 51Week 51
4614/12/2020Week 51Week 51
4715/12/2020Week 51Week 51
4824/12/2020Week 52Week 52
4924/12/2020Week 52Week 52
5022/02/2021Week 9Week 9
5122/02/2021Week 9Week 9
5222/02/2021Week 9Week 9
Sheet1
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
is that what you want?
Need DateWeekNew WeekCustom
17/09/2020Week 38Week 41Week 41
17/09/2020Week 38Week 41Week 41
18/09/2020Week 38Week 41Week 41
25/09/2020Week 39Week 41Week 41
29/09/2020Week 40Week 41Week 41
30/09/2020Week 40Week 41Week 41
30/09/2020Week 40Week 41Week 41
01/10/2020Week 40Week 41Week 41
02/10/2020Week 40Week 41Week 41
02/10/2020Week 40Week 41Week 41
02/10/2020Week 40Week 41Week 41
02/10/2020Week 40Week 41Week 41
02/10/2020Week 40Week 41Week 41
05/10/2020Week 41Week 41Week 41
06/10/2020Week 41Week 41Week 41
07/10/2020Week 41Week 41Week 41
13/10/2020Week 42Week 42Week 42
14/10/2020Week 42Week 42Week 42
15/10/2020Week 42Week 42Week 42
19/10/2020Week 43Week 43Week 43
19/10/2020Week 43Week 43Week 43
21/10/2020Week 43Week 43Week 43
26/10/2020Week 44Week 44Week 44
27/10/2020Week 44Week 44Week 44
27/10/2020Week 44Week 44Week 44
05/11/2020Week 45Week 45Week 45
05/11/2020Week 45Week 45Week 45
06/11/2020Week 45Week 45Week 45
09/11/2020Week 46Week 46Week 46
09/11/2020Week 46Week 46Week 46
09/11/2020Week 46Week 46Week 46
16/11/2020Week 47Week 47Week 47
17/11/2020Week 47Week 47Week 47
17/11/2020Week 47Week 47Week 47
23/11/2020Week 48Week 48Week 48
23/11/2020Week 48Week 48Week 48
24/11/2020Week 48Week 48Week 48
02/12/2020Week 49Week 49Week 49
02/12/2020Week 49Week 49Week 49
02/12/2020Week 49Week 49Week 49
07/12/2020Week 50Week 50Week 50
07/12/2020Week 50Week 50Week 50
07/12/2020Week 50Week 50Week 50
14/12/2020Week 51Week 51Week 51
14/12/2020Week 51Week 51Week 51
15/12/2020Week 51Week 51Week 51
24/12/2020Week 52Week 52Week 52
24/12/2020Week 52Week 52Week 52
22/02/2021Week 9Week 9Week 41
22/02/2021Week 9Week 9Week 41
22/02/2021Week 9Week 9Week 41

if not I'll try to understand what you want to achieve
 
Last edited:
Upvote 0
ignore post above
so here is
Need DateWeekNew WeekCustom
17/09/2020Week 38Week 41Week 41
17/09/2020Week 38Week 41Week 41
18/09/2020Week 38Week 41Week 41
25/09/2020Week 39Week 41Week 41
29/09/2020Week 40Week 41Week 41
30/09/2020Week 40Week 41Week 41
30/09/2020Week 40Week 41Week 41
01/10/2020Week 40Week 41Week 41
02/10/2020Week 40Week 41Week 41
02/10/2020Week 40Week 41Week 41
02/10/2020Week 40Week 41Week 41
02/10/2020Week 40Week 41Week 41
02/10/2020Week 40Week 41Week 41
05/10/2020Week 41Week 41Week 41
06/10/2020Week 41Week 41Week 41
07/10/2020Week 41Week 41Week 41
13/10/2020Week 42Week 42Week 42
14/10/2020Week 42Week 42Week 42
15/10/2020Week 42Week 42Week 42
19/10/2020Week 43Week 43Week 43
19/10/2020Week 43Week 43Week 43
21/10/2020Week 43Week 43Week 43
26/10/2020Week 44Week 44Week 44
27/10/2020Week 44Week 44Week 44
27/10/2020Week 44Week 44Week 44
05/11/2020Week 45Week 45Week 45
05/11/2020Week 45Week 45Week 45
06/11/2020Week 45Week 45Week 45
09/11/2020Week 46Week 46Week 46
09/11/2020Week 46Week 46Week 46
09/11/2020Week 46Week 46Week 46
16/11/2020Week 47Week 47Week 47
17/11/2020Week 47Week 47Week 47
17/11/2020Week 47Week 47Week 47
23/11/2020Week 48Week 48Week 48
23/11/2020Week 48Week 48Week 48
24/11/2020Week 48Week 48Week 48
02/12/2020Week 49Week 49Week 49
02/12/2020Week 49Week 49Week 49
02/12/2020Week 49Week 49Week 49
07/12/2020Week 50Week 50Week 50
07/12/2020Week 50Week 50Week 50
07/12/2020Week 50Week 50Week 50
14/12/2020Week 51Week 51Week 51
14/12/2020Week 51Week 51Week 51
15/12/2020Week 51Week 51Week 51
24/12/2020Week 52Week 52Week 52
24/12/2020Week 52Week 52Week 52
22/02/2021Week 9Week 9Week 9
22/02/2021Week 9Week 9Week 9
22/02/2021Week 9Week 9Week 9

is that what you want?
 
Upvote 0
Yes that's exactly what I want to see in terms of the data, I actually only need 2 columns though, the "NEED DATE" and "WEEK".

I only included the "New Week" to show what i needed the result to look like if that makes sense
 
Upvote 0
sure, add custom column "Week" with
if Date.Year([Need Date]) > Date.Year(DateTime.LocalNow()) then "Week "&Text.From(Date.WeekOfYear([Need Date])) else if Date.WeekOfYear([Need Date]) < Date.WeekOfYear(DateTime.LocalNow()) or Date.Year([Need Date]) < Date.Year(DateTime.LocalNow()) then "Week "&Text.From(Date.WeekOfYear(DateTime.LocalNow())) else "Week "&Text.From(Date.WeekOfYear([Need Date]))
 
Upvote 0
You are welcome
It's nice to see if someone appreciate your work with (y) Like
Have a nice day
 
Upvote 0
shorter version
if Date.IsInNextYear([Need Date]) then "Week "&Text.From(Date.WeekOfYear([Need Date])) else if Date.WeekOfYear([Need Date]) < Date.WeekOfYear(DateTime.LocalNow()) then "Week "&Text.From(Date.WeekOfYear(DateTime.LocalNow())) else "Week "&Text.From(Date.WeekOfYear([Need Date]))
 
Last edited:
Upvote 0
or even
"Week "&Text.From(if Date.IsInNextYear([Need Date]) then Date.WeekOfYear([Need Date]) else if Date.WeekOfYear([Need Date]) < Date.WeekOfYear(DateTime.LocalNow()) then Date.WeekOfYear(DateTime.LocalNow()) else Date.WeekOfYear([Need Date]))
 
Upvote 0

Forum statistics

Threads
1,224,272
Messages
6,177,634
Members
452,787
Latest member
BeeTH

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