Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
itsme
Resolver I
Resolver I

Use From and To date columns to create list of dates per person

I have a table that shows PTO for employees. There is a To and From date columns, then columns for Hours and Hours Per Day. Instead of using the From and To columns, I want to create a list of dates for each employee that will be taking PTO on those days with the number of hours for each day.

 

For example, if Art has PTO from 5/30/2022 to 6/3/2022 and Marc has PTO only on 5/30/2022, the table will look like this:

EmployeeFromToHoursHours Per Day
Art5/30/20226/3/2022326.4
Marc5/30/20226/3/202288

 

I want to transform the table in PQ so it looks like this:

EmployeeDateHours
Art5/30/20226.4
Art5/31/20226.4
Art6/1/20226.4
Art6/2/20226.4
Art6/3/20226.4
Marc5/30/20228

 

Any idea how I can do that?

 

Thank you in advance!!

2 ACCEPTED SOLUTIONS
wdx223_Daniel
Super User
Super User

NewStep=#table({"Employee","Date","Hours"},List.TransformMany(Table.ToRows(PreviousStepName),each List.Dates(_{1},Duration.Days(_{2}-_{1})+1,Duation.From(1)),(x,y)=>{x{0},y,_{4}}))

View solution in original post

@wdx223_Daniel I just realized Duration was spelled incorrectly. Now I have an error in each value for Hours:

 

itsme_0-1660077992558.png

 

View solution in original post

4 REPLIES 4
itsme
Resolver I
Resolver I

@wdx223_Daniel Figured it out! Thanks so much for your help! I was playing with the x-y variables and replaced y with x (see screenshot below), then realized x by itself is giving the columns as a list, starting from 0.

itsme_1-1660080541729.png

 

So, I replaced _{4} with x{4} to give me the column 4 from the original table into the Hours column.

itsme_2-1660080750177.png

 

 

Thanks again!

 

wdx223_Daniel
Super User
Super User

NewStep=#table({"Employee","Date","Hours"},List.TransformMany(Table.ToRows(PreviousStepName),each List.Dates(_{1},Duration.Days(_{2}-_{1})+1,Duation.From(1)),(x,y)=>{x{0},y,_{4}}))

@wdx223_Daniel I'm showing this error: "Expression.Error: The import Duation.From matches no exports. Did you miss a module reference?" I'm having a hard time figuring out this peice of code.

 

itsme_0-1660075091875.png

 

@wdx223_Daniel I just realized Duration was spelled incorrectly. Now I have an error in each value for Hours:

 

itsme_0-1660077992558.png

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors