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.
I have a dataset, It has a colume name "Dealno" (Text) and another "Rowlastupdated" (DateTime).
The "Dealno" row is repeted everythime someone makes a change and it is timestamped in "Rowlastupdated"
I am trying to filter out thru Power Query to only show the latest "Dealno" row from the "Rowelastupdated" column.
can this be done in power query to filter the entire table.
Thanks for any help.
Solved! Go to Solution.
Hard to tell what you are doing wrong. Even from the UI, the column names don't change for the simple example of two columns -- one with the dealno and one with the date. When you enter the name of your max date column, it can be whatever you want (even the same as the original date column).
If you are expanding a subtable, you may have to edit that step in the Advanced Editor to get rid of the "renaming" which the UI generated step wants to do. That is merely a matter of deleting the optional newcolumnnames argument.
Hi @nrowey
You can refer to the following code to advanced editor in power query
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTIyMDLWN9Q3UorVQREwRRUwQxcw1zcECyTBBEzRBcxAArEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type date}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Column1"}, {{"MaxDate", each List.Max([Column2]), type nullable date}, {"Data", each _, type table [Column1=nullable text, Column2=nullable date]}}),
#"Expanded Data" = Table.ExpandTableColumn(#"Grouped Rows", "Data", {"Column2"}, {"Column2"}),
#"Added Conditional Column" = Table.AddColumn(#"Expanded Data", "Custom", each if [MaxDate] = [Column2] then 1 else 0),
#"Filtered Rows" = Table.SelectRows(#"Added Conditional Column", each ([Custom] = 1)),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"MaxDate", "Custom"})
in
#"Removed Columns"
It will not change the column name, you can also see it in the attachments.
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I will try this next time around Thanks
Is there any other way besides a Group By , I already have all the visuals built.
Below is a measure that works but I am trying to get the results in power query........
What am I missing?
I don't understand why the method would make a difference. The end result will be the same in PQ. Please explain.
You could also do this by
But that would take much longer to run and the end result would be the same.
Grouping
#"Grouped Rows" = Table.Group(#"Changed Type", {"Dealno"}, {
{"MaxRowLastUpdated", each List.Max([Rowlastupdated]), type nullable date}
})
Filtering
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each
let
dn=Table.SelectRows(#"Changed Type", (r)=>r[Dealno]=[Dealno]),
maxDate=Table.SelectRows(dn, each [Rowlastupdated]=List.Max(dn[Rowlastupdated]))
in
maxDate,
type table[Dealno=text, Rowlastupdated=date]),
The reason I dont want to set up a group-by is all the Visuals are completed. When ever I set up a Group-by the column names all change and I have to start over building visuals etc.?
Or maybe I am doing somthing wrong?
Hard to tell what you are doing wrong. Even from the UI, the column names don't change for the simple example of two columns -- one with the dealno and one with the date. When you enter the name of your max date column, it can be whatever you want (even the same as the original date column).
If you are expanding a subtable, you may have to edit that step in the Advanced Editor to get rid of the "renaming" which the UI generated step wants to do. That is merely a matter of deleting the optional newcolumnnames argument.
I did not reliize I could rename to exsisting column names.. This worked Thanks so much...
Group by "Dealno" and aggregate by "Max" of "Rowlastupdated"