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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Coltella8013
Frequent Visitor

Help converting list of items with date range into a table for each occurrence per date

Hi. I am fairly new to PowerBI and am trying to work out the best approach to achieveing the following and would appreciate some assistance?

 

Table Source Data Example:

ItemTypeStart DateEnd Date
Item 1Type 101/01/202110/01/2021
Item 2Type 203/01/202110/01/2021
Item 3Type 105/01/202110/01/2021
Item 4Type 107/01/202108/01/2021

 

End Goal - Count how many Items occurred within a slidable date range using an existing Date table.

I am looking to try achieve the following (a row item per date per item) so that I can pivot by Type and date slider.

 

01/01/2021Item 1Type 1
02/01/2021Item 1Type 1
03/01/2021Item 1Type 1
03/01/2021Item 2Type 2
04/01/2021Item 1Type 1
04/01/2021Item 2Type 2
05/01/2021Item 1Type 1
05/01/2021Item 3Type 1
05/01/2021Item 2Type 2
06/01/2021Item 1Type 1
06/01/2021Item 3Type 1
06/01/2021Item 2Type 2
07/01/2021Item 1Type 1
07/01/2021Item 3Type 1
07/01/2021Item 4Type 1
07/01/2021Item 2Type 2
08/01/2021Item 1Type 1
08/01/2021Item 3Type 1
08/01/2021Item 4Type 1
08/01/2021Item 2Type 2
09/01/2021Item 1Type 1
09/01/2021Item 3Type 1
09/01/2021Item 2Type 2
10/01/2021Item 1Type 1
10/01/2021Item 3Type 1
10/01/2021Item 2Type 2

 

Any help would be much appreciated.

 

Regards.

Nigel

2 ACCEPTED SOLUTIONS
Payeras_BI
Super User
Super User

Hi @Coltella8013 ,

 

In PQ editor go to Add Custom Column and paste the code below: 

 

List.Dates([Start Date], Duration.Days([End Date] - [Start Date]), #duration(1, 0, 0, 0))

 

 

Payeras_BI_0-1611590203362.png

Now you can already remove Start and End Date columns and click on "Expand to New Rows":

Payeras_BI_0-1611591179881.png

 

Payeras_BI_1-1611591332505.png

 

 

Regards,

 

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

View solution in original post

v-deddai1-msft
Community Support
Community Support

Hi @Coltella8013 ,

 

You can create a custom column to get list from start date and end date:

{Number.From([Start Date])..Number.From([End Date])}

Capture.PNG

Then expand list to rows and change the type to date:

Capture1.PNGCapture2.PNG

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

View solution in original post

2 REPLIES 2
v-deddai1-msft
Community Support
Community Support

Hi @Coltella8013 ,

 

You can create a custom column to get list from start date and end date:

{Number.From([Start Date])..Number.From([End Date])}

Capture.PNG

Then expand list to rows and change the type to date:

Capture1.PNGCapture2.PNG

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

Payeras_BI
Super User
Super User

Hi @Coltella8013 ,

 

In PQ editor go to Add Custom Column and paste the code below: 

 

List.Dates([Start Date], Duration.Days([End Date] - [Start Date]), #duration(1, 0, 0, 0))

 

 

Payeras_BI_0-1611590203362.png

Now you can already remove Start and End Date columns and click on "Expand to New Rows":

Payeras_BI_0-1611591179881.png

 

Payeras_BI_1-1611591332505.png

 

 

Regards,

 

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.