#table
TableCreates a table literal from column names and a list of row value lists.
Syntax
#table(columnSpecification as any, rows as list) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
columnSpecification | any | Yes | Either a list of column name strings, or a table type expression specifying column names and types. |
rows | list | Yes | A list of lists, where each inner list contains the values for one row in column order. |
Return Value
table — A table with the specified columns and rows.
Remarks
#table is M's literal constructor for creating table values inline. It is most commonly used in query steps to define small reference tables, test fixtures, or lookup tables without relying on an external data source.
The first argument can be either a plain list of column name strings ({"A", "B"}) or a table type that also specifies column types (type table [A = text, B = number]). Using a typed table type causes M to enforce or coerce the column types.
Each inner list in rows must have the same number of elements as there are columns. If a row has too few elements, M will error at evaluation time.
Examples
Example 1: Create a simple two-column table
#table({"Name", "Score"}, {{"Alice", 95}, {"Bob", 82}, {"Carol", 78}})Result
Name | Score | |
|---|---|---|
| 1 | Alice | 95 |
| 2 | Bob | 82 |
| 3 | Carol | 78 |
Example 2: Create a typed table with column types enforced
#table(
type table [Product = text, Price = number],
{{"Widget", 9.99}, {"Gadget", 24.99}}
)Result
Product | Price | |
|---|---|---|
| 1 | Widget | 9.99 |
| 2 | Gadget | 24.99 |
Example 3: Empty table with column names
#table({"ID", "Name"}, {})Result
ID | Name |
|---|
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks