Type.TableSchema

Type

Returns a table describing the columns of a table type, including column names, positions, type names, and kinds.

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

Syntax

Type.TableSchema(type as type) as table

Parameters

NameTypeRequiredDescription
typetypeYesA table type whose schema is described.

Return Value

tableA table with columns Name, Position, TypeName, and Kind describing each column of the table type.

Remarks

Type.TableSchema returns a table that describes the columns declared in a table type. The result has four columns:

- Name — the column name as text - Position — the zero-based column index (0 for the first column) - TypeName — the column's type as a text string (e.g., "number", "text", "nullable number") - Kind — the kind of the type as text (e.g., "Primitive" for type number, "Nullable" for type nullable number)

This function operates on a table type value — not the table itself. Pass Value.Type(table) to obtain the table's type before calling Type.TableSchema.

Type.TableSchema provides a human-readable, table-formatted alternative to Type.TableColumn for inspecting schemas. Common uses include:

- Programmatic schema inspection: determining column count, order, names, and types in one call - Documentation generation: producing a schema summary that can be returned or logged - Generic validation: filtering for columns of a specific kind or type name before applying transforms

For structured programmatic access to individual column types, prefer Type.TableColumn. For key information, use Type.TableKeys.

Examples

Example 1: Get the full schema of a typed table

let
    T = #table(
        type table [OrderID = number, Product = text, UnitPrice = nullable number],
        {{1, "Widget A", 25.0}}
    ),
    Schema = Type.TableSchema(Value.Type(T))
in
    Schema
Applied Steps

The final output — the schema table showing all three columns with their positions, type names, and kinds.

Name
Position
TypeName
Kind
1OrderID0numberPrimitive
2Product1textPrimitive
3UnitPrice2nullable numberNullable

Example 2: Count columns declared in the Sales table type

Result
Result
18

Example 3: Find all nullable columns in a table type

let
    T = #table(
        type table [OrderID = number, Product = text, Notes = nullable text],
        {{1, "Widget A", null}}
    ),
    Schema = Type.TableSchema(Value.Type(T)),
    NullableCols = Table.SelectRows(Schema, each [Kind] = "Nullable")
in
    NullableCols[Name]
Applied Steps

The final output — extracts the Name column from the filtered schema table, returning a list of nullable column names.

Result
1Notes

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks