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' column. This is my code so far...

let
    Source = x_optional,
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Year", "year"}})
in
    #"Renamed Columns"

 Thanks

  • 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"
     

     

3 Replies

  • VijayP's avatar
    VijayP
    Community Champion

    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"
     

     

    • adavid999's avatar
      adavid999
      Helper V

      Thank you VijayP , that worked. not sure though what you mean re streamline column names and previous step names?