Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Filter a column in Power Query by position?

Hi everyone,

I have a simple table like:

DateDayMonthYear
    

To filter Day, I could use = Table.SelectRows(Source, each ([Day] = "Monday")) for example. But I wonder if there is a way to filter the second column of the table instead of stating the column name?

I tried = Table.SelectRows(Source, each ([Table.ColumnNames(Source){2}] = "Monday")) but it didn't work.

Thank you.

  • Hi Anonymous ,
    you are on the right track with that approach. Just change it to:

    Table.SelectRows(Source, each (Record.Field(_, Table.ColumnNames(Source){2}) = "Monday")) 

2 Replies

  • ImkeF's avatar
    ImkeF
    Community Champion

    Hi Anonymous ,
    you are on the right track with that approach. Just change it to:

    Table.SelectRows(Source, each (Record.Field(_, Table.ColumnNames(Source){2}) = "Monday"))