Create list of non-consecutive dates using M...

Matty

Well-known Member
Joined
Feb 17, 2007
Messages
3,717
Hi again,

Next problem: how to create a list of non-consecutive dates in Power Query.

Source data as follows:

Dates
11/12/2017
18/12/2017
25/12/2017
01/01/2018
08/01/2018
15/01/2018
22/01/2018
18/12/2017
25/12/2017
01/01/2018
08/01/2018
15/01/2018
22/01/2018

<tbody>
</tbody>

Table (list) to be generated:

Dates
11/12/2017
18/12/2017
25/12/2017
01/01/2018
08/01/2018
15/01/2018
22/01/2018

<tbody>
</tbody>

In other words, the earliest and latest dates needs to be identified from the source data, and then a list of dates 7 days apart should be generated (the dates are always a Monday).

Anyone have any ideas how this could be achieved?

Cheers,

Matty
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
That would be:

Code:
= List.Dates(List.Min(Source),1+Duration.Days(List.Max(Source)-List.Min(Source))/7,#duration(7,0,0,0))
 
Upvote 0
Not in front of a PC, but if you pull your dates in as one column table and right click at the top you can select drill down and convert it to a list. You can then use List.Max and List.Min to find the highest and smallest date.

Once you have those you can use List.Generate, the first example on the power query website can be adapted. Bear in mind that dates are just an integer under the hood, so you can add 7 like you would in excel.
 
Upvote 0
@gazpage: unlike Excel, in Power Query numbers and dates are incompatible.
It is possible to add a duration to a date, and it is possible to concatenate dates and times ([date] & [time]), resulting in date/time values, but you can't add a number to a date.
 
Upvote 0

Forum statistics

Threads
1,214,570
Messages
6,120,294
Members
448,953
Latest member
Dutchie_1

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