OpenBI Docs Buy

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
ParameterTypeDescription
tabletableThe 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.Select to 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"}

Table.ColumnCount, Table.HasColumns, Table.ColumnsOfType, Table.Schema.

Last updated · OpenBI Studio 0.3.79