Forum Discussion
Power query date consolidation
- 6 years ago
sauravguha , shared solution in PM. Created start date and end dates based on the continuous streak
Sure, here you go...
| Name | Property | Date From | Date To | Leave Type |
| Smith | ABC | 2020-04-01 | 2020-04-05 | AL |
| Smith | ABC | 2020-04-06 | 2020-04-16 | AL |
| Smith | ABC | 2020-04-17 | 2020-04-30 | SL |
| Smith | ABC | 2020-03-26 | 2020-03-28 | SL |
| David | BCD | 2020-03-26 | 2020-03-28 | AL |
| David | BCD | 2020-04-28 | 2020-04-30 | AL |
| David | BCD | 2020-03-12 | 2020-03-12 | SL |
| Monty | BCD | 2020-04-17 | 2020-04-30 | AL |
| Monty | BCD | 2020-04-01 | 2020-04-09 | AL |
| Sid | ABC | 2020-03-10 | 2020-03-10 | AL |
| Sid | ABC | 2020-03-11 | 2020-03-11 | AL |
| Sid | ABC | 2020-03-15 | 2020-03-15 | AL |
| Sid | ABC | 2020-03-19 | 2020-03-24 | SL |
| Sid | ABC | 2020-03-25 | 2020-03-31 | SL |
| Sid | ABC | 2020-04-01 | 2020-04-05 | AL |
Expected Result:
| Name | Property | Date From | Date To | Leave Type |
| Smith | ABC | 26/03/2020 | 28/03/2020 | SL |
| Smith | ABC | 01/04/2020 | 16/04/2020 | AL |
| Smith | ABC | 17/04/2020 | 30/04/2020 | SL |
| David | BCD | 12/03/2020 | 12/03/2020 | SL |
| David | BCD | 01/04/2020 | 09/04/2020 | AL |
| David | BCD | 17/04/2020 | 30/04/2020 | AL |
| Sid | ABC | 10/03/2020 | 15/03/2020 | AL |
| Sid | ABC | 19/03/2020 | 31/03/2020 | SL |
| Sid | ABC | 01/04/2020 | 05/04/2020 | AL |
- v-easonf-msft6 years ago
Community Support
Hi, sauravguha
Here is demo.
If help ,try follow steps:
1.Add custom as below and expend the list:
=List.Dates([Date From],Duration.Days([Date To]-[Date From])+1,#duration(1,0,0,0))2. Remove two column "Date From " and "Date to"
3. Then group rows as below3.Add custom colum "split"as below
=Table.Group(let a = [Data] in Table.AddColumn(a, "New" ,each let d = [Date], t = Table.AddColumn( Table.SelectRows(a, each [Date] <=d),"Temp", each Duration.Days(d-[Date]) ) in Table.Min(Table.SelectRows(t, each [Temp] <=Table.RowCount(t)),"Date")[Date]), {"New"}, {{"Date To", each List.Max([Date]), type date}})4.Then remove the column "Data " and expand the column "Split"
If I misunderstood your request, please explain more about your calculation logic.
And I am afraid the excepted result you attached is a bit wrong, as i dont see anywhere Monty's record.
Best Regards,
Community Support Team _ Eason- sauravguha6 years ago
Helper I
Thank you so much for the assistance, it works very well. will try on a live data and let you know if i face any challenge.
- sauravguha6 years ago
Helper I
Hello Thanks for taking time to attend to my query. I have only one issue. If i have a date range like 26 Mar - 30 Mar 2020 and another one from 1 Apr - 30 Apr 2020, the query is merging it to show 26 Mar - 30 April 2020 when it should remain same since 31st March 2020 is missing in between. How can we sort this small issue? Thanks again. Saurav
- v-easonf-msft6 years ago
Community Support
Hi , sauravguha
Not very clear .It is recommended to open another thread to explain your additional problem in more detail.
Best Regards,
Community Support Team _ Eason