PowerQuery: Inserting New Columns based on certain criteria

Jose Fonyat

New member
Joined
Aug 30, 2017
Messages
13
Reaction score
0
Points
0
Location
Brazil
Excel Version(s)
Microsoft 365 Apps Versao 2007
Dear members, let me know if you can help me with this problem:

My table is the following:

CustomerIdCustomerStartEndN.Days
John115/12/201718/12/20173
Bruce210/01/201712/01/20172






My Goal is to achieve this new table:

The idea is:
- Create as many rows as the N.Days and repeat all content
- Create a new column and insert the correspondent date of use (DayUse)

NameIdCustomerStartEndN.DaysDayUse
John115/12/201718/12/2017315/12/2017
John115/12/201718/12/2017316/12/2017
John115/12/201718/12/2017317/12/2017
Bruce210/01/201712/01/2017210/01/2017
Bruce210/01/201712/01/2017211/01/2017










Thanks a lot
Best Regards
 
First, add a column with formula ={1..[N.Days]}
You may use the default column name "Custom".
Next, expand this column (2-arrows-button in the column header).
Next, add a column "DayUse" with formula = Date.AddDays([Start],[Custom]-1).
Finally, remove column "Custom".
 
Thanks a Lot Marcel!

Best Regards!!!
 
I realise this is an old thread; I'm using them as practice to learn.

I'm guessing that in the 2.5 years since Marcel posted his solution List.Dates has been made available, which can reduce the number of steps:
Instead of:
First, add a column with formula ={1..[N.Days]}
try starting by adding a column named DayUse:
= List.Dates([Start],[N.Days],#duration(1,0,0,0))
and expanding that. No columns to remove.
 
Back
Top