Forum Discussion
Anonymous
3 years agoNot applicable
Dynamic Max of each column Grouped by ID
I have a step where I am retreiving the max of each column grouped by ID (#"Grouped Rows"). I want to convert this step to a dynamic function (dynamic list of columns) that takes all the columns in t...
- 3 years ago
let tbl = Table.FromRecords({ [SiteID = 1, Address = "123 street", City = "C", State = null], [SiteID = 2, Address = null, City = "C", State = "O"], [SiteID = 1, Address = null, City = "C", State = "O"], [SiteID = 2, Address = "234 street", City = null, State = "O"] }), tcn = List.Skip(Table.ColumnNames(tbl)), tbl1 = Table.Group(tbl, {"SiteID"}, {{"All", each Table.SelectColumns(_, tcn)}}), tbl2 = Table.TransformColumns(tbl1, {{"All", (t)=> let lst = Table.ToColumns(t), lst1 = List.Transform(lst, each List.Accumulate(_, "", (s,c)=> if c <> null then let ct = Text.From(c) in (if Text.Length(ct) > Text.Length(s) then ct else s) else s)) in Table.FromRows({lst1}, tcn) }}), Result = Table.ExpandTableColumn(tbl2, "All", tcn) in Result
Anonymous
3 years agoNot applicable
Thank You ❤️❤️❤️❤️