Forum Discussion
cottrera
Post Prodigy
4 years agoMax date per unique id
Hi I have a facts table with two columns Unit ref, Completed Data. The unit ref can appear on more than one line , but with a different completed date. I need a measure column that displ...
- 4 years ago
Hey cottrera ,
It can be done using "Group By" in Power Query.
See the screenshot of the parameters arrangement in Group By
And this is the advanced editor code:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Zc/LDcQwCATQXnyOxB/jWqL030YCa8lCe30ChrnvoTJF57gGEQQw0hrPdY+YPuNTQUBLxsYsgDVNjckBNdmKKU0hhekIA6dwyXTT/5ytBnZCtq26R22bDFBSpWkAZhJp6X4R5IR7+PJdp5Kic+w6q/Ov0ffp8wI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Unit ref" = _t, #"Completed Date" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Unit ref", Int64.Type}, {"Completed Date", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Unit ref"}, {{"Max", each List.Max([Completed Date]), type nullable text}, {"All rows", each _, type table [Unit ref=nullable number, Completed Date=nullable text]}}), #"Expanded All rows" = Table.ExpandTableColumn(#"Grouped Rows", "All rows", {"Completed Date"}, {"Completed Date"}) in #"Expanded All rows"The outcome will be:
cottrera
Post Prodigy
4 years agoThank you it works fine 😀