Forum Discussion

adavid999's avatar
adavid999
Helper V
4 years ago
Solved

filter max in M

Hello, is it possible to set up filter in M so table only shows max value in 'year' column? If so, please can you show code for this? I would like to filter my table to only show max value in 'year' ...
  • VijayP's avatar
    4 years ago

    adavid999 

     

    Try this , you need to streamline column names and previous step names

    let
        Source = x_optional,
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", Int64.Type}}),
        #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Year", "year"}})
        #"Filtered Rows" = Table.SelectRows(#"Renamed Columns", each ([year] = List.Max(#"Renamed Columns"[year])))
    in
        #"Filtered Rows"