Table.ColumnNames
The names of a table's columns, in their order, as a list of texts.
Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Table.ColumnNames(table as table) as list
| Parameter | Type | Description |
|---|---|---|
table | table | The table to look at. |
Returns
list. The column names, first column first.
Remarks
- Use it to work on columns whose names you don't know ahead, for example with
List.Selectto find every column that starts with "Sales".
Examples
A table's columns
Table.ColumnNames(#table({"Product", "Price", "Units"}, {{"Chair", 50, 4}, {"Desk", 120, 1}, {"Lamp", 30, 6}}))
{"Product", "Price", "Units"}
The columns that start with "Sales"
let
Months = #table({"Shop", "Sales Jan", "Sales Feb"}, {{"Oslo", 120, 135}})
in
List.Select(Table.ColumnNames(Months), each Text.StartsWith(_, "Sales"))
{"Sales Jan", "Sales Feb"}
Related functions
Table.ColumnCount, Table.HasColumns, Table.ColumnsOfType, Table.Schema.