Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello,
Assuming I have a table like down below with ID and LastUpdated columns, I'd like to get a flag to where this particular ID has most recent (up to date) date. Ideally I'd like to have that in PQ. Is it something to achieve?
ID | LastUpdated | Flag |
ID1 | 10.06.2022 | |
ID1 | 11.06.2022 | |
ID1 | 14.06.2022 | 1 |
Solved! Go to Solution.
Hi @Pbiuserr ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can achieve it in Power Query Editor:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nQxVNJRMtM3NNA3MjAyUorVQRIzxCJmgixmBBYzxxQyNIOKxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, LastUpdated = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"LastUpdated", type date}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {{"Maxdate", each List.Max([LastUpdated]), type nullable date}, {"Details", each _, type table [ID=nullable text, LastUpdated=nullable date]}}),
#"Expanded Details" = Table.ExpandTableColumn(#"Grouped Rows", "Details", {"LastUpdated"}, {"LastUpdated"}),
#"Added Custom" = Table.AddColumn(#"Expanded Details", "Flag", each if [LastUpdated]=[Maxdate] then 1 else null),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Maxdate"})
in
#"Removed Columns"
Best Regards
Hi @Pbiuserr ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can achieve it in Power Query Editor:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nQxVNJRMtM3NNA3MjAyUorVQRIzxCJmgixmBBYzxxQyNIOKxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, LastUpdated = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"LastUpdated", type date}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {{"Maxdate", each List.Max([LastUpdated]), type nullable date}, {"Details", each _, type table [ID=nullable text, LastUpdated=nullable date]}}),
#"Expanded Details" = Table.ExpandTableColumn(#"Grouped Rows", "Details", {"LastUpdated"}, {"LastUpdated"}),
#"Added Custom" = Table.AddColumn(#"Expanded Details", "Flag", each if [LastUpdated]=[Maxdate] then 1 else null),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Maxdate"})
in
#"Removed Columns"
Best Regards
Assuming your Table is called Table, make a new calculated column for Flag and use the following:
Flag =
User | Count |
---|---|
117 | |
73 | |
58 | |
49 | |
48 |
User | Count |
---|---|
171 | |
122 | |
60 | |
59 | |
56 |