Forum Discussion
The last date
- 1 year ago
Hello ElinG
You can solve this issue with the following step
1)Create a copy of your table and name it for FilterDate (or the name you want to give)
2) Delete all columns excpept snap_month
3) Select the column then Transform --> Date --> Latest
you should have something like this
4) In your intitial table, Applied a filter on the date (select one date in your list)
You will get something like:= Table.SelectRows(#"Changed Type", each ([snap_month ] = #date(2025, 2, 15)))
5) Replace date(2025, 2, 15) by FilterDate (or the name you gave to your table)Tadam, you only get the last value, each time you will refresh, your filteredtable will be updated
If it is not what you are trying to achieve, let me know 🙂
- 1 year ago
Hi ElinG ,
If you have a column like Org_partner_nr (not unique) and a snap_month column (representing a time snapshot), and you want to keep only the latest snap_month for each Org_partner_nr, here’s how you can do it in Power Query:
-
Sort the table by snap_month in descending order.
-
Then go to the "Home" tab and use "Group By".
-
In the Group By window: Group by: Org_partner_nr >> Operation: Select "All Rows" (this will nest the grouped data).
-
Add a custom column inside the nested tables to extract the top row (the latest one).
-
Expand the nested tables to bring the full row back.
Or alternatively, if you're comfortable with code, you can use something like this in M:
let SortedTable = Table.Sort(YourTable, {{"Org_partner_nr", Order.Ascending}, {"snap_month", Order.Descending}}), GroupedTable = Table.Group(SortedTable, {"Org_partner_nr"}, {{"Latest", each Table.FirstN(_, 1)}}), ExpandedTable = Table.ExpandTableColumn(GroupedTable, "Latest", Table.ColumnNames(SortedTable)) in ExpandedTable -
Hi ElinG ,
If you have a column like Org_partner_nr (not unique) and a snap_month column (representing a time snapshot), and you want to keep only the latest snap_month for each Org_partner_nr, here’s how you can do it in Power Query:
-
Sort the table by snap_month in descending order.
-
Then go to the "Home" tab and use "Group By".
-
In the Group By window: Group by: Org_partner_nr >> Operation: Select "All Rows" (this will nest the grouped data).
-
Add a custom column inside the nested tables to extract the top row (the latest one).
-
Expand the nested tables to bring the full row back.
Or alternatively, if you're comfortable with code, you can use something like this in M:
let
SortedTable = Table.Sort(YourTable, {{"Org_partner_nr", Order.Ascending}, {"snap_month", Order.Descending}}),
GroupedTable = Table.Group(SortedTable, {"Org_partner_nr"}, {{"Latest", each Table.FirstN(_, 1)}}),
ExpandedTable = Table.ExpandTableColumn(GroupedTable, "Latest", Table.ColumnNames(SortedTable))
in
ExpandedTable