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!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hello everyone,
This is what my actual data look like:
| Id | Start Time | End Time |
| 1 | 08:00 | 08:34 |
| 2 | 03:12 | 05:27 |
And this is what I want the table as below:
| Id | Start Time | End Time |
| 1 | 08:00 | 08:34 |
| 2 | 03:12 | 04:00 |
| 2 | 04:00 | 05:00 |
| 2 | 05:00 | 05:27 |
Any help would be great! Thanks.
Solved! Go to Solution.
Hi @rajulshah ,
you can do this in the query editor like so:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTKwsDIwgNDGJkqxOtFKRiCesZUhmDa1MjJXio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Id = _t, #"Start Time" = _t, #"End Time" = _t]),
CreateListOfFullHours = Table.AddColumn(Source, "AllFullHours", each { Number.From(Text.BeforeDelimiter([Start Time], ":")) .. Number.From(Text.BeforeDelimiter([End Time], ":")) }),
TransformListOfFullHoursAndSkipFirstHour = Table.AddColumn(CreateListOfFullHours, "SkipFirstHour", each List.Transform(List.Skip([AllFullHours]), each Text.PadStart(Text.From(_), 2, "0") & ":00")),
CreateNewTable = Table.AddColumn(TransformListOfFullHoursAndSkipFirstHour, "Result", each Table.FromColumns( { {[Start Time]} & [SkipFirstHour], [SkipFirstHour] & {[End Time] } }, { "Start Time", "End Time" } )),
Cleanup = Table.RemoveColumns(CreateNewTable,{"Start Time", "End Time", "AllFullHours", "SkipFirstHour"}),
#"Expanded Result" = Table.ExpandTableColumn(Cleanup, "Result", {"Start Time", "End Time"}, {"Start Time", "End Time"})
in
#"Expanded Result"
Simply paste this code into the advanced editor and follow the steps.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Create an hourly period table.
Then Create a new table like this. If this give period span correctly , then you can use logic to put correct start and end time for each period.
summarize(filter(table,(table[start]<=min(period[start_period]) || table[end] >=max(period[end_period])))
,table[start],table[end],period[start_period],period[end_period],table[id])
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin
Hi @rajulshah ,
you can do this in the query editor like so:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTKwsDIwgNDGJkqxOtFKRiCesZUhmDa1MjJXio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Id = _t, #"Start Time" = _t, #"End Time" = _t]),
CreateListOfFullHours = Table.AddColumn(Source, "AllFullHours", each { Number.From(Text.BeforeDelimiter([Start Time], ":")) .. Number.From(Text.BeforeDelimiter([End Time], ":")) }),
TransformListOfFullHoursAndSkipFirstHour = Table.AddColumn(CreateListOfFullHours, "SkipFirstHour", each List.Transform(List.Skip([AllFullHours]), each Text.PadStart(Text.From(_), 2, "0") & ":00")),
CreateNewTable = Table.AddColumn(TransformListOfFullHoursAndSkipFirstHour, "Result", each Table.FromColumns( { {[Start Time]} & [SkipFirstHour], [SkipFirstHour] & {[End Time] } }, { "Start Time", "End Time" } )),
Cleanup = Table.RemoveColumns(CreateNewTable,{"Start Time", "End Time", "AllFullHours", "SkipFirstHour"}),
#"Expanded Result" = Table.ExpandTableColumn(Cleanup, "Result", {"Start Time", "End Time"}, {"Start Time", "End Time"})
in
#"Expanded Result"
Simply paste this code into the advanced editor and follow the steps.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 64 | |
| 56 | |
| 43 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 123 | |
| 108 | |
| 44 | |
| 32 | |
| 26 |