Forum Discussion
Calculate the highest date value for people with the same ID.
- 3 years ago
Hi Adn1 ,
How about this:
Before:
After:
Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough). The idea is to join the query from after the grouping (calculating MaxDate per ID) with the original query before the grouping:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcsxLVNJRUjAEEkYm+gaG+kYGRsZKsTrRSu6lxSWJZTBJoAyypE9+aWYxSM7YFEgaGugbGIEkjSA6E5NSUeQMoXKxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [NAME = _t, ID = _t, END_DATE = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"NAME", type text}, {"ID", Int64.Type}, {"END_DATE", type date}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {{"MaxDate", each List.Max([END_DATE]), type nullable date}}), #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"ID"}, #"Grouped Rows", {"ID"}, "Grouped Rows", JoinKind.LeftOuter), #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"MaxDate"}, {"MaxDate"}) in #"Expanded Grouped Rows"Let me know if this helps 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
Hi Adn1 ,
How about this:
Before:
After:
Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough). The idea is to join the query from after the grouping (calculating MaxDate per ID) with the original query before the grouping:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcsxLVNJRUjAEEkYm+gaG+kYGRsZKsTrRSu6lxSWJZTBJoAyypE9+aWYxSM7YFEgaGugbGIEkjSA6E5NSUeQMoXKxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [NAME = _t, ID = _t, END_DATE = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"NAME", type text}, {"ID", Int64.Type}, {"END_DATE", type date}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {{"MaxDate", each List.Max([END_DATE]), type nullable date}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"ID"}, #"Grouped Rows", {"ID"}, "Grouped Rows", JoinKind.LeftOuter),
#"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"MaxDate"}, {"MaxDate"})
in
#"Expanded Grouped Rows"
Let me know if this helps 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
thanks!