#table
Builds a table in M from its column names (or a table type) and its rows, each a list of values.
Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
#table(columns as any, rows as any) as table
| Parameter | Type | Description |
|---|---|---|
columns | any | A list of column names; a table type, which gives the columns' types too; or a number of columns, named Column1, Column2 ... |
rows | any | A list of rows, each a list of values in column order. |
Returns
table. The table, its columns typed when a table type was given.
Remarks
- Each row needs as many values as there are columns.
- A small table typed by hand is the quickest way to try a step: every example on these pages starts from one.
Examples
Names and rows
#table({"Product", "Price"}, {{"Chair", 50}, {"Desk", 120}})
| Product | Price |
|---|---|
| Chair | 50 |
| Desk | 120 |
With a table type
The type gives each column its type, as Table.Schema shows.
Table.Schema(#table(type table [Product = text, Price = number], {{"Chair", 50}}))[[Name], [Kind]]
| Name | Kind |
|---|---|
| Product | text |
| Price | number |
A number of columns
#table(2, {{"Chair", 50}})
| Column1 | Column2 |
|---|---|
| Chair | 50 |
Related functions
Table.FromRecords, Table.FromRows, Table.Schema, Table.ColumnNames.