Forum Discussion

Petri's avatar
Petri
Frequent Visitor
3 years ago
Solved

Using a parameter to refer to a column in Power Query

I try to use a parameter to select a (date) column and then filter the latest value in that column. The name of the column varies in source files but is always the first column, so I tried:   Firs...
  • ppm1's avatar
    3 years ago

    You can use this syntax in your Filtered Rows step.

     

    = let firstcolumn = Table.ColumnNames(Source){0},
    latestdate = List.Max(Table.Column(Source, firstcolumn))
    in
    Table.SelectRows(Source, each Record.Field(_, firstcolumn) = latestdate)

     

    Replace Source with your previous step name throughout.

     

    Pat