#table

Table

Creates a table literal from column names and a list of row value lists.

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

Syntax

#table(columnSpecification as any, rows as list) as table

Parameters

NameTypeRequiredDescription
columnSpecificationanyYesEither a list of column name strings, or a table type expression specifying column names and types.
rowslistYesA list of lists, where each inner list contains the values for one row in column order.

Return Value

tableA 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
1Alice95
2Bob82
3Carol78

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
1Widget9.99
2Gadget24.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