Atmira
Atmira

Reputation: 249

Remove Column based on Column position/index number

In PowerBI, M-language I need to remove a specific column number (number 5) for each table column in multiple files. So far I have managed to remove the column by name, but the naming of column 5 varies, I want to remove the column by its columnnumber instead of its columnname.

= Table.RemoveColumns(
  Table.PromoteHeaders(Csv.Document([Content], [Delimiter = ";", Columns = 11, Encoding = 1252])), 
  "ColumnName"
)

Thanks in advance

Upvotes: 0

Views: 1471

Answers (1)

horseyride
horseyride

Reputation: 21318

= Table.RemoveColumns(x,Table.ColumnNames(x){4})

so then probably

= Table.RemoveColumns(
  Table.PromoteHeaders(Csv.Document([Content], [Delimiter = ";", Columns = 11, Encoding = 1252]))
, Table.ColumnNames(Table.PromoteHeaders(Csv.Document([Content], [Delimiter = ";", Columns = 11, Encoding = 1252]))){4}
)

Upvotes: 1

Related Questions