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
sauravguha can you post the data in table format and expected output, it is very hard to read the blurb of data.
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 |
- sauravguha6 years ago
Helper I
Any luck Sir?- 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.