Table.ColumnNames
TableReturns the column names of a table as a list of text values.
Syntax
Table.ColumnNames(table as table) as listParameters
| Name | Type | Required | Description |
|---|---|---|---|
table | table | Yes | The table whose column names to return. |
Return Value
list — A 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 | |
|---|---|
| 1 | OrderID |
| 2 | CustomerName |
| 3 | Product |
| 4 | Category |
| 5 | UnitPrice |
| 6 | Quantity |
| 7 | OrderDate |
| 8 | Region |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks