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
chrisvdwal
New Member

Create table with 1/2 hour time slots

Hi,

I have a requirement to create a table with a new records for each ½ time slot from a record in another table which has a date/time range

 

Source table

 

StartTime                            FinishTime

1/1/2019 11:00 am         1/1/2019 13:00 pm

 

Should return 4 records in temp table

 

StartTime

1/1/2019 11:00am

1/1/2019 11:30am

1/1/2019 12:00pm

1/1/2019 12:30pm

 

Ranges can go over days    1/1/2019 23:00pm -> 4/1/2019 02:am  would create lots of records (48 per day)

 

Is this possiable?

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@chrisvdwal here are query steps on sample data which you can use as per your need

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMLRUMDS0MjBQSMw9tAAElXSUIAwQVEAosjI2UCjIVYrVIVknWGsiUGssAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [StartTime = _t, EndTime = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"StartTime", type datetime}, {"EndTime", type datetime}}),
    #"Inserted Age" = Table.AddColumn(#"Changed Type", "Time", each List.DateTimes([StartTime],(Duration.TotalMinutes([EndTime]-[StartTime])/30)+1,#duration(0,0,30,0))),
    #"Expanded Time" = Table.ExpandListColumn(#"Inserted Age", "Time"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Time",{{"Time", type datetime}})
in
    #"Changed Type1"


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @chrisvdwal 

Look at GENERATESERIES function.

Thanks!

parry2k
Super User
Super User

@chrisvdwal here are query steps on sample data which you can use as per your need

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMLRUMDS0MjBQSMw9tAAElXSUIAwQVEAosjI2UCjIVYrVIVknWGsiUGssAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [StartTime = _t, EndTime = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"StartTime", type datetime}, {"EndTime", type datetime}}),
    #"Inserted Age" = Table.AddColumn(#"Changed Type", "Time", each List.DateTimes([StartTime],(Duration.TotalMinutes([EndTime]-[StartTime])/30)+1,#duration(0,0,30,0))),
    #"Expanded Time" = Table.ExpandListColumn(#"Inserted Age", "Time"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Time",{{"Time", type datetime}})
in
    #"Changed Type1"


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.