Forum Discussion
Anonymous
6 years agoNot applicable
Sum workload per maximum Timestamp per caseID
I need to calculate Sumworkload, per ID, for the maximum timestamp per day, per assignment group. Sum workload is the result I would like to have. ID Timestamp Assignment Group Workload ...
- Anonymous6 years ago
split the time_stamp column in two columns "day" and "stamp" then try this:
rr = Table.Group(youTab, {"id", "day"}, {{"sum", (s)=> List.Sum(Table.SelectRows(s, each [stamp]=List.Max(s[stamp]))[work])},{"cols", each _}}), te= Table.ExpandTableColumn(yourTab, "cols", {"stamp", "group", "work"}, {"stamp", "group", "work"}) in te - 6 years ago
Hi Anonymous
As tested, Rocco_sprmnt21's answer works.
To add "per assignment group" in your conditions, please modify the query as below and paste in your Advanced editor.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jdDBCoAgDADQXwnPCdtu9SviQXNIFxWFvj+Fyg5FHcbG2GNsSgkjRkEoURIQDIQzQO0Yu3BNWCMmDjVJEnp8Gsc+3uQahpSjz1zKt3JNyVZnNqWsPrD7uetV2aboVADnQVs4DroR7Hu6mK4XuEehdw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Timestamp = _t, #"Assignment Group" = _t, Workload = _t, Activity = _t, Sumworkload = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"Timestamp", type text}, {"Assignment Group", type text}, {"Workload", Int64.Type}, {"Activity", type text}, {"Sumworkload", Int64.Type}}), #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Timestamp", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"day", "stamp"}), rr = Table.Group(#"Split Column by Delimiter", {"ID", "day","Assignment Group"}, {{"sum", (s)=> List.Sum(Table.SelectRows(s, each [stamp]=List.Max(s[stamp]))[Workload])},{"cols", each _}}), #"Grouped Rows" = Table.Group(rr, {"ID", "day"}, {{"sum2", each List.Sum([sum]), type number}, {"all", each _, type table [ID=text, day=text, Assignment Group=text, sum=number, cols=table]}}), #"Expanded all" = Table.ExpandTableColumn(#"Grouped Rows", "all", {"cols"}, {"all.cols"}), #"Expanded all.cols" = Table.ExpandTableColumn(#"Expanded all", "all.cols", {"stamp", "Assignment Group", "Workload", "Activity"}, {"all.cols.stamp", "all.cols.Assignment Group", "all.cols.Workload", "all.cols.Activity"}) in #"Expanded all.cols"Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
6 years agoNot applicable
split the time_stamp column in two columns "day" and "stamp" then try this:
rr = Table.Group(youTab, {"id", "day"}, {{"sum", (s)=> List.Sum(Table.SelectRows(s, each [stamp]=List.Max(s[stamp]))[work])},{"cols", each _}}),
te= Table.ExpandTableColumn(yourTab, "cols", {"stamp", "group", "work"}, {"stamp", "group", "work"})
in
te