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
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 below
3.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
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- sauravguha6 years ago
Helper I
Hi, thanks for your assistance and sorry for not being able to clarify as needed. Below is a new example where i believe i would be able to explain more.
In the first 2 names, Prasanna, since he has two sets of leave dates which are not in continuation, expected result is same as Given data. However, on the name "Said", his first 2 leaves are in continuation, hence, expected result is a date range combining the same and making one and his 3rd date range is kept in a separate row since it is not in continuation with the first two date ranges.
Was i able to make it clearer? Thank you again for assisting.
Given Data Expected result Emp ID Name Start Date End Date Leave Type Emp ID Name Start Date End Date Leave Type E1545 Prasanna 23-Mar-20 30-Mar-20 AL E1545 Prasanna 23-Mar-20 30-Mar-20 AL E1545 Prasanna 01-Apr-20 30-Apr-20 AL E1545 Prasanna 01-Apr-20 30-Apr-20 AL E116460 Said 10-Mar-20 16-Mar-20 SL E116460 Said 10-Mar-20 19-Mar-20 SL E116460 Said 17-Mar-20 19-Mar-20 SL E116460 Said 28-Apr-20 30-Apr-20 SL E116460 Said 28-Apr-20 30-Apr-20 SL E115838 Suraj 31-Mar-20 06-Apr-20 AL E115838 Suraj 31-Mar-20 06-Apr-20 AL E115838 Suraj 11-Apr-20 15-Apr-20 AL E115838 Suraj 11-Apr-20 15-Apr-20 AL E18433 Manikandan 22-Mar-20 15-Apr-20 AL E18433 Manikandan 22-Mar-20 28-Mar-20 AL E116043 George 22-Mar-20 23-Apr-20 SL E18433 Manikandan 29-Mar-20 15-Apr-20 AL E115882 Permeshwar 26-Mar-20 30-Mar-20 AL E116043 George 22-Mar-20 06-Apr-20 SL E115882 Permeshwar 01-Apr-20 30-Apr-20 AL E116043 George 07-Apr-20 15-Apr-20 SL E115587 Illeperumage 18-Mar-20 19-Mar-20 AL E116043 George 16-Apr-20 23-Apr-20 SL E115587 Illeperumage 23-Mar-20 26-Mar-20 AL E115882 Permeshwar 26-Mar-20 30-Mar-20 AL E115587 Illeperumage 17-Apr-20 30-Apr-20 AL E115882 Permeshwar 01-Apr-20 30-Apr-20 AL E117332 Hosny 01-Mar-20 11-Mar-20 SL E115587 Illeperumage 18-Mar-20 19-Mar-20 AL E117332 Hosny 26-Mar-20 30-Apr-20 AL E115587 Illeperumage 23-Mar-20 26-Mar-20 AL E115587 Illeperumage 17-Apr-20 30-Apr-20 AL E117332 Hosny 01-Mar-20 01-Mar-20 SL E117332 Hosny 02-Mar-20 02-Mar-20 SL E117332 Hosny 03-Mar-20 03-Mar-20 SL E117332 Hosny 04-Mar-20 04-Mar-20 SL E117332 Hosny 05-Mar-20 05-Mar-20 SL E117332 Hosny 06-Mar-20 06-Mar-20 SL E117332 Hosny 07-Mar-20 07-Mar-20 SL E117332 Hosny 08-Mar-20 08-Mar-20 SL E117332 Hosny 09-Mar-20 09-Mar-20 SL E117332 Hosny 10-Mar-20 10-Mar-20 SL E117332 Hosny 11-Mar-20 11-Mar-20 SL E117332 Hosny 26-Mar-20 16-Apr-20 AL E117332 Hosny 17-Apr-20 24-Apr-20 AL E117332 Hosny 25-Apr-20 30-Apr-20 AL - amitchandak6 years ago
Super User
sauravguha , shared solution in PM. Created start date and end dates based on the continuous streak