PQ grouping 2 weeks

shophoney

Active Member
Joined
Jun 16, 2014
Messages
281
Hi, I have created a power query calendar.

I need to group 2 weeks at a time for payroll.

Starting on Mondays.

How can I make a grouping interval be 14 days starting on Mondays.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Here is an example of what Sandy is talking about.

Code:
let
    Source = Table.FromList(List.Dates(#date(2019, 1, 7), 364, #duration(1, 0, 0, 0)), Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    Index = Table.AddIndexColumn(Source, "Index", 1, 1),
    Mod = Table.AddColumn(Index, "Custom", each Number.RoundUp([Index]/14,0)),
    Group = Table.Group(Mod, {"Custom"}, {{"Count", each _, type table}}),
    Combine = Table.AddColumn(Group, "Custom.1", each Text.Combine(List.Transform(Table.Column([Count],"Column1"),Text.From),",")),
    Split = Table.SplitColumn(Combine, "Custom.1", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Custom.1.1", "Custom.1.2", "Custom.1.3", "Custom.1.4", "Custom.1.5", "Custom.1.6", "Custom.1.7", "Custom.1.8", "Custom.1.9", "Custom.1.10", "Custom.1.11", "Custom.1.12", "Custom.1.13", "Custom.1.14"}),
    Remove = Table.RemoveColumns(Split,{"Count"}),
    Transpose = Table.Transpose(Remove),
    PromotedHeaders = Table.PromoteHeaders(Transpose, [PromoteAllScalars=true]),
    DOW = Table.AddColumn(PromotedHeaders, "Day Of Week", each Date.DayOfWeekName([1])),
    Order = Table.ReorderColumns(DOW,{"Day Of Week", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26"})
in
    Order

Book1
DEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1Day Of Week1234567891011121314151617181920212223242526
2Monday1/7/20191/21/20192/4/20192/18/20193/4/20193/18/20194/1/20194/15/20194/29/20195/13/20195/27/20196/10/20196/24/20197/8/20197/22/20198/5/20198/19/20199/2/20199/16/20199/30/201910/14/201910/28/201911/11/201911/25/201912/9/201912/23/2019
3Tuesday1/8/20191/22/20192/5/20192/19/20193/5/20193/19/20194/2/20194/16/20194/30/20195/14/20195/28/20196/11/20196/25/20197/9/20197/23/20198/6/20198/20/20199/3/20199/17/201910/1/201910/15/201910/29/201911/12/201911/26/201912/10/201912/24/2019
4Wednesday1/9/20191/23/20192/6/20192/20/20193/6/20193/20/20194/3/20194/17/20195/1/20195/15/20195/29/20196/12/20196/26/20197/10/20197/24/20198/7/20198/21/20199/4/20199/18/201910/2/201910/16/201910/30/201911/13/201911/27/201912/11/201912/25/2019
5Thursday1/10/20191/24/20192/7/20192/21/20193/7/20193/21/20194/4/20194/18/20195/2/20195/16/20195/30/20196/13/20196/27/20197/11/20197/25/20198/8/20198/22/20199/5/20199/19/201910/3/201910/17/201910/31/201911/14/201911/28/201912/12/201912/26/2019
6Friday1/11/20191/25/20192/8/20192/22/20193/8/20193/22/20194/5/20194/19/20195/3/20195/17/20195/31/20196/14/20196/28/20197/12/20197/26/20198/9/20198/23/20199/6/20199/20/201910/4/201910/18/201911/1/201911/15/201911/29/201912/13/201912/27/2019
7Saturday1/12/20191/26/20192/9/20192/23/20193/9/20193/23/20194/6/20194/20/20195/4/20195/18/20196/1/20196/15/20196/29/20197/13/20197/27/20198/10/20198/24/20199/7/20199/21/201910/5/201910/19/201911/2/201911/16/201911/30/201912/14/201912/28/2019
8Sunday1/13/20191/27/20192/10/20192/24/20193/10/20193/24/20194/7/20194/21/20195/5/20195/19/20196/2/20196/16/20196/30/20197/14/20197/28/20198/11/20198/25/20199/8/20199/22/201910/6/201910/20/201911/3/201911/17/201912/1/201912/15/201912/29/2019
9Monday1/14/20191/28/20192/11/20192/25/20193/11/20193/25/20194/8/20194/22/20195/6/20195/20/20196/3/20196/17/20197/1/20197/15/20197/29/20198/12/20198/26/20199/9/20199/23/201910/7/201910/21/201911/4/201911/18/201912/2/201912/16/201912/30/2019
10Tuesday1/15/20191/29/20192/12/20192/26/20193/12/20193/26/20194/9/20194/23/20195/7/20195/21/20196/4/20196/18/20197/2/20197/16/20197/30/20198/13/20198/27/20199/10/20199/24/201910/8/201910/22/201911/5/201911/19/201912/3/201912/17/201912/31/2019
11Wednesday1/16/20191/30/20192/13/20192/27/20193/13/20193/27/20194/10/20194/24/20195/8/20195/22/20196/5/20196/19/20197/3/20197/17/20197/31/20198/14/20198/28/20199/11/20199/25/201910/9/201910/23/201911/6/201911/20/201912/4/201912/18/20191/1/2020
12Thursday1/17/20191/31/20192/14/20192/28/20193/14/20193/28/20194/11/20194/25/20195/9/20195/23/20196/6/20196/20/20197/4/20197/18/20198/1/20198/15/20198/29/20199/12/20199/26/201910/10/201910/24/201911/7/201911/21/201912/5/201912/19/20191/2/2020
13Friday1/18/20192/1/20192/15/20193/1/20193/15/20193/29/20194/12/20194/26/20195/10/20195/24/20196/7/20196/21/20197/5/20197/19/20198/2/20198/16/20198/30/20199/13/20199/27/201910/11/201910/25/201911/8/201911/22/201912/6/201912/20/20191/3/2020
14Saturday1/19/20192/2/20192/16/20193/2/20193/16/20193/30/20194/13/20194/27/20195/11/20195/25/20196/8/20196/22/20197/6/20197/20/20198/3/20198/17/20198/31/20199/14/20199/28/201910/12/201910/26/201911/9/201911/23/201912/7/201912/21/20191/4/2020
15Sunday1/20/20192/3/20192/17/20193/3/20193/17/20193/31/20194/14/20194/28/20195/12/20195/26/20196/9/20196/23/20197/7/20197/21/20198/4/20198/18/20199/1/20199/15/20199/29/201910/13/201910/27/201911/10/201911/24/201912/8/201912/22/20191/5/2020
Sheet2
 
Upvote 0
@lrobbo314
try with DateTime.LocalNow() and defined End date but not hardcoded start date and duration :)
2020 = 366 days :)
 
Last edited:
Upvote 0
Thanks @lrobbo314 ,
OP didn't say what kind of Calendar he/she has and what will be the end result so hard to say what kind of solution should be
 
Upvote 0

Forum statistics

Threads
1,214,894
Messages
6,122,124
Members
449,066
Latest member
Andyg666

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