This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hi,
I want to split the datetime columns range into multiple rows as shown below.
ID| punch_Start | punch_End
--------------------------------------------
A | 2019-03-04 23:18:00| 2019-03-04 23:21:00
--------------------------------------------
A | 2019-03-04 23:45:00| 2019-03-05 00:15:00
--------------------------------------------
Required Output-
ID| punch_Start | punch_End
--------------------------------------------
A | 2019-03-04 23:18:00| 2019-03-04 23:21:00
--------------------------------------------
A | 2019-03-04 23:45:00| 2019-03-04 23:59:00
--------------------------------------------
A | 2019-03-04 23:59:00| 2019-03-05 00:00:00
--------------------------------------------
A | 2019-03-05 00:00:00| 2019-03-05 00:15:14
Please let me know how can I achieve this.
Hi, @Vatz8
let
Source = your_last_step,
types = Table.TransformColumnTypes(Source,{{"punch_Start", type datetime}, {"punch_End", type datetime}}),
f = (lst as list) =>
[id = lst{0},
end = lst{2},
gen =
List.Buffer(
List.Generate(
() => lst{1},
(x) => x < end,
(x) =>
if DateTime.Time(x) = #time(23, 59, 00)
then x + #duration(0, 0, 1, 0)
else DateTime.From(DateTime.Date(x)) + #duration(0, 23, 59, 0)
)
),
dts = List.Zip({List.Repeat({id}, List.Count(gen)), gen, List.RemoveFirstN(gen, 1) & {end}})][dts],
rows = List.Buffer(Table.ToRows(types)),
txform_rows = List.Combine(List.Transform(rows, f)),
z = Table.FromRows(txform_rows, Table.ColumnNames(Source))
in
z
Please don't cross post your questions
Split Datetime range columns into multiple rows fo... - Microsoft Fabric Community
Thanks
Phil
Proud to be a Super User!
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.