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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Igarsaba
Regular Visitor

Dates between create columns

Hi guys, i need some help

 

I have a table with Start Date and End Date for each employee

I need to create one row for each day between these two date, repeating the employee names.

 

Is there a way to do that?

2 ACCEPTED SOLUTIONS
ChielFaber
Super User
Super User

I had a similar usecase within my work environment and I solved this using M powerquery.

 

They idea is to create a list with dates between the start data and the enddate

 You can create a new column containing the list with dates as followed:

 

Table.AddColumn(  #"PreviousStepName", "NewColumnName", each List.Dates([Startdate], Duration.Days([Enddate] - [startdate]), #duration(1,0,0,0)
    ))
 
With this code you get a new column containing for each row a list with dates between the startdate and enddate. In the next step you simply expand the list and as a result you get a row for each date between the startdate and enddate.
 
For example when the startdate is 1-1-2023 and the enddate is 10-1-2023 you get a row for each day.

View solution in original post

In this case, the last day isnt beeing created, what parameter defines that?

View solution in original post

5 REPLIES 5
ChielFaber
Super User
Super User

I had a similar usecase within my work environment and I solved this using M powerquery.

 

They idea is to create a list with dates between the start data and the enddate

 You can create a new column containing the list with dates as followed:

 

Table.AddColumn(  #"PreviousStepName", "NewColumnName", each List.Dates([Startdate], Duration.Days([Enddate] - [startdate]), #duration(1,0,0,0)
    ))
 
With this code you get a new column containing for each row a list with dates between the startdate and enddate. In the next step you simply expand the list and as a result you get a row for each date between the startdate and enddate.
 
For example when the startdate is 1-1-2023 and the enddate is 10-1-2023 you get a row for each day.

In this case, the last day isnt beeing created, what parameter defines that?

Do you mean if the enddate is null? You could choose to replace those values with the date from DateTime.LocalNow from https://learn.microsoft.com/en-us/powerquery-m/datetime-localnow

 

If that isn't what your saying could you then provide a small example table with dummy data

Add 1 to the "Count" parameter:  

 

List.Dates([Start], Duration.Days([End] - [Start])+1, #duration(1,0,0,0))
johnt75
Super User
Super User

You could create a calculated table in DAX

Employee dates =
SELECTCOLUMNS (
    GENERATE ( Employee, CALENDAR ( Employee[Start date], Employee[End date] ) ),
    "Employee first name", Employee[First name],
    "Employee last name", Employee[Last name],
    "Date", [Date]
)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.