Forum Discussion
Create a filtred table based on an agregation function
- 5 years ago
Hi,
This M code works
let Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"AlertID", Int64.Type}, {"status", type text}, {"Date", type date}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"AlertID"}, {{"Max", each List.Max([Date]), type nullable date}, {"All", each _, type table [AlertID=nullable number, status=nullable text, Date=nullable date]}}), #"Expanded All" = Table.ExpandTableColumn(#"Grouped Rows", "All", {"status", "Date"}, {"status", "Date"}), #"Added Custom" = Table.AddColumn(#"Expanded All", "Custom", each [Max]=[Date]), #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] = true)), #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Max", "Custom"}), #"Sorted Rows" = Table.Sort(#"Removed Columns",{{"AlertID", Order.Ascending}}) in #"Sorted Rows"Hope this helps.
Hi wahib_mouhoubi ,
What I want to achieve is also to let you see the latest status of each individual alert. You can see the result of the operation below. When data is updated, the corresponding results will also be updated to ensure the latest status of each alert.
Maybe I'm not getting what actually you are trying to do.
Could you please share the expected result to have a clear understanding of your question?
Hope that's what you were looking for.
Best Regards,
Yuna
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Hi,
Ashish_Mathur sent me the PowerQuery M code i needed, i accepted it as a solution.
Thank you all !