Forum Discussion
spread calls duration that exceed 30 mins over multiple 30 mins intervals over the day.
- 6 years ago
Hello Anonymous
I've created something really nice
But I think the logic has to be changed, meaning, creating a talble, considering the lowest start time and the highest end time and then connect to the call-table to do the calculation
let Quelle = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTWMzTSMzIwtFQwsLAyMFDSQRMyNgUKJSfm5CjF6qArNzFFU26JrDwWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Start = _t, End = _t, Type = _t]), ChangeType = Table.TransformColumnTypes ( Quelle, { {"Start", type datetime}, {"End", type datetime}, {"Type", type text} } ), GetListTimesStart = List.DateTimes ( List.Min ( ChangeType[Start] ) - #duration(0,0,Time.Minute ( List.Min ( ChangeType[Start] ) ),0), Duration.Minutes ( List.Max ( ChangeType[End] ) - List.Min ( ChangeType[Start] ) ) / 30+2, #duration(0,0,30,0) ), GetListTimeEnd = List.Transform(GetListTimesStart, each _ + #duration(0,0,30,0)), CreateTabel = Table.FromColumns({GetListTimesStart,GetListTimeEnd}, {"Start", "End"}), AddCallTable = Table.AddColumn ( CreateTabel, "Merge Tables", (Time)=> Table.SelectRows ( ChangeType, (select)=> select[Start]<=Time[End] and Time[Start] <= select[End] ) ), ExpandCallTimes = Table.ExpandTableColumn ( AddCallTable, "Merge Tables", {"Start", "End", "Type"}, {"Call.Start", "Call.End", "Type"} ), ChangeToDateTime = Table.TransformColumnTypes ( ExpandCallTimes, { {"Start", type datetime}, {"End", type datetime}, {"Call.Start", type datetime}, {"Call.End", type datetime}} ), CalculateDuration = Table.AddColumn ( ChangeToDateTime, "Duration", each Duration.TotalSeconds ( (if [End]<[Call.End] then [End] else [Call.End])- (if [Call.Start]>[Start] then [Call.Start] else [Start]) ) ), DeleteCallColumns = Table.RemoveColumns ( CalculateDuration, {"Call.Start", "Call.End"} ) in DeleteCallColumnsWhat do you think about it?
If this post helps or solves your problem, please mark it as solution.
Kudos are nice to - thanks
Have fun
Jimmy
Hi everyone,
I am having some difficulties figuring out how to shape my table the way I would like to with power Query.
I would like to keep only the duplicated numbers in RemoteID Column when MediaType Column contains value =6 and then compute the difference in time between the first line and 2nd line as showed in picture below.
Thank you in advance
Hello Anonymous
could you please create a new post for this issue
Thanks
Jimmy
- Anonymous6 years agoNot applicable
Hi Jimmy,
yes it is a different issue should be a new post. thanks for the note. I did a new post.
thanks in advance.