Forum Discussion
rajulshah
6 years agoResident Rockstar
Expand rows into intermediate time values
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 En...
- 6 years ago
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.
amitchandak
6 years agoSuper User
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