Forum Discussion
list.generate from a list
- 4 years ago
here is how I managed to do it.
First of all, let me explain the full process. (I should have started with this)
Users are asked to encode their planning workload for the coming year. They fill in a form with those 7 fields.
userId, projectId, starting_date, ending_date, hours, repeateveryweek, repeat_end_date
for example, user 01, working on project "alpha" plans to work 8h/day from "07/03/2022" to "09/03/2022" and repeat this workload every 1 week until the end of July.
01,"alpha","07/03/2022","09/03/2022",8,1,"31/07/2022".
what I want, at the end is something like this until end of julyuserId projectid listdate hours 01 alpha 07/03/2022 8 01 alpha 08/03/2022 8 01 alpha 09/03/2022 8 01 alpha 14/03/2022 8 01 alpha 15/03/2022 8 01 alpha 16/03/2022 8 01 alpha 21/03/2022 8 01 alpha 22/03/2022 8 01 alpha 23/03/2022 8 01 alpha 28/03/2022 8 01 alpha 29/03/2022 8 01 alpha 30/03/2022 8 01 alpha 04/04/2022 8 01 alpha 05/04/2022 8 01 alpha 06/04/2022 8 what I did:
I first converted startdate and endate to a list of dates using List.Dates([start_date],Duration.Days([end_date]-[start_date])+1, #duration(1,0,0,0)))
then I splitted the list in new rows with = Table.ExpandListColumn
Last I repeated this process but this time using the repeat_end_date instead of end_date
= List.Dates([ListDate],(Duration.Days([repeat_end_date]-[ListDate])+1)/7*repeateveryweek, #duration(7*repeateveryweek,0,0,0))
And split that list again in new rows.
thanks for all your inputs. it helped me figuring out how to solve this.