Table.ToColumns
TableReturns a list of lists, where each inner list contains the values of one column.
Syntax
Table.ToColumns(table as table) as listParameters
| Name | Type | Required | Description |
|---|---|---|---|
table | table | Yes | The table to convert. |
Return Value
list — A list of lists, one inner list per column, in column order.
Remarks
Table.ToColumns is the inverse of Table.FromColumns. It returns a list of lists — one per column — where each inner list contains all values in that column in row order.
This is useful for transposing data, passing column data to list functions, or zipping columns together.
Examples
Example 1: Extract all column values as lists
let
Source = #table({"A", "B"}, {{1, 4}, {2, 5}, {3, 6}}),
Columns = Table.ToColumns(Source)
in
ColumnsThe final output — converts the table into a list of lists, one inner list per column: the first inner list contains all values from column A and the second from column B.
Result | |
|---|---|
| 1 | {{1,2,3},{4,5,6}} |
Example 2: Transpose a table using ToColumns and FromColumns
let
Source = #table({"A","B","C"},{{1,2,3},{4,5,6}}),
Cols = Table.ToColumns(Source),
Transposed = Table.FromColumns(Cols)
in
TransposedThe final output — reconstructs a table from the column lists using Table.FromColumns, effectively swapping rows and columns so that the original columns become rows.
Column1 | Column2 | |
|---|---|---|
| 1 | 1 | 4 |
| 2 | 2 | 5 |
| 3 | 3 | 6 |