Forum Discussion

davidz106's avatar
davidz106
Helper III
4 years ago
Solved

Remove all columns after certain value

I want to remove all columns after the column that is named "Q3". How should I write this in M?

 

The number of columns before Q3 is dynamic. 

 

Regrads,

Dave

  • Insert following statement where you can replace Source with previous step

    = Table.RemoveColumns(Source,List.RemoveRange(Table.ColumnNames(Source),0,List.PositionOf(Table.ColumnNames(Source),"Q3")+1))

2 Replies

  • Vijay_A_Verma's avatar
    Vijay_A_Verma
    Most Valuable Professional

    Insert following statement where you can replace Source with previous step

    = Table.RemoveColumns(Source,List.RemoveRange(Table.ColumnNames(Source),0,List.PositionOf(Table.ColumnNames(Source),"Q3")+1))