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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
sonm10
Helper I
Helper I

Generating rows from date difference

Hello Experts, I have a event schedule as below

 

FromToDayStartEnd
1/1/20201/31/2020Mon7:00 AM3:00 PM
1/1/20201/31/2020Tue8:00 AM4:00 PM
1/1/20201/31/2020Wed9:00 AM5:00 PM
1/1/20201/31/2020Thu10:00 AM6:00 PM
1/1/20201/31/2020Fri11:00 AM7:00 PM
1/1/20201/31/2020Sat12:00 PM8:00 PM
1/1/20201/31/2020Sun1:00 PM9:00 PM

 

The schedule is maintained in periods and day. Now i want to expand that table to show the schedule for each date as below.

 

DateDayStartEnd
1/1/2020Wednesday9:00 AM5:00 PM
1/2/2020Thursday10:00 AM6:00 PM
1/3/2020Friday11:00 AM7:00 PM
1/4/2020Saturday12:00 PM8:00 PM
1/5/2020Sunday1:00 PM9:00 PM
1/6/2020Monday7:00 AM3:00 PM
1/7/2020Tuesday8:00 AM4:00 PM
1/8/2020Wednesday9:00 AM5:00 PM
1/9/2020Thursday10:00 AM6:00 PM
1/10/2020Friday11:00 AM7:00 PM
1/11/2020Saturday12:00 PM8:00 PM
1/12/2020Sunday1:00 PM9:00 PM
1/13/2020Monday7:00 AM3:00 PM
1/14/2020Tuesday8:00 AM4:00 PM
1/15/2020Wednesday9:00 AM5:00 PM
1/16/2020Thursday10:00 AM6:00 PM
1/17/2020Friday11:00 AM7:00 PM
1/18/2020Saturday12:00 PM8:00 PM
1/19/2020Sunday1:00 PM9:00 PM
1/20/2020Monday7:00 AM3:00 PM
1/21/2020Tuesday8:00 AM4:00 PM
1/22/2020Wednesday9:00 AM5:00 PM
1/23/2020Thursday10:00 AM6:00 PM
1/24/2020Friday11:00 AM7:00 PM
1/25/2020Saturday12:00 PM8:00 PM
1/26/2020Sunday1:00 PM9:00 PM
1/27/2020Monday7:00 AM3:00 PM
1/28/2020Tuesday8:00 AM4:00 PM
1/29/2020Wednesday9:00 AM5:00 PM
1/30/2020Thursday10:00 AM6:00 PM
1/31/2020Friday11:00 AM

7:00 PM

 

 

I have found that we can generate a date list with the Date.List function. In the function, we have to provide the starting date, the number of rows required and the increment number.

 

First I need to calculate the first date of a period corresponing to the given Day. In the above example, I first need the date of the first monday so I can use that as the start date for my list.

 

Additionally, I need the number of Days in a given period. In the above example, I have to find the number of mondays in the given period to find the number of rows to be created.

 

I am stuck with finding the first date for a day in a given period and finding the number of particular days in the period.

3 REPLIES 3
camargos88
Community Champion
Community Champion

Hi @sonm10 ,

 

Check this file:  Download PBIX 

 

Capture.PNG

 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Thank you @camargos88 for the solution. However I am not able to get my time schedules (it only shows  date fields)when I expand the table. Can you explain the various step in your PBIX.

Hi @sonm10 ,

 

1) Create a table with your dates;

2) Create a column with the weekday name;

3) Merge the new and old table by the weekday name to get the times (start/end);

4) Expand the merged table;

 

Could you download the pbix ?

 

 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.