Table.ColumnNames

Table

Returns the column names of a table as a list of text values.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Table.ColumnNames(table as table) as list

Parameters

NameTypeRequiredDescription
tabletableYesThe table whose column names to return.

Return Value

listA list of text values representing the column names, in order.

Remarks

Table.ColumnNames returns the column names of a table as a list of text values, preserving the column order. This is useful for dynamic operations where you need to reference columns programmatically — for example, selecting all columns except a few, or building dynamic unpivot operations.

A common pattern is combining Table.ColumnNames with List.RemoveItems to get all column names except certain ones, then passing the result to Table.SelectColumns or Table.UnpivotOtherColumns.

Examples

Example 1: List column names

let
    Names = Table.ColumnNames(Sales)
in
    #table({"ColumnName"}, List.Transform(Names, each {_}))
Result
ColumnName
1OrderID
2CustomerName
3Product
4Category
5UnitPrice
6Quantity
7OrderDate
8Region

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks