Downloads
Power Query MErrors and typesAdvanced

Type.TableSchema

Returns a table that describes the columns of a table type: their names and their types.

Syntax
Type.TableSchema(tableType)

Returns: A table with one row for each column, showing the column name and its type information.

What it does

Type.TableSchema reads the schema of a table type, which is the description of its columns. It returns a table, one row per column, with the column name and details of its type. Use it to check that a loaded file has the columns and types you expect, or to build a control that fails when the layout changes.

Syntax and arguments

Example

A monthly file is supposed to have the same layout every time. The query checks the schema before it loads the rows and stops if a required column is missing.

let
    Source = Csv.Document(File.Contents("C:\Banking\statement-2026-03.csv"), [Delimiter = ","]),
    Headers = Table.PromoteHeaders(Source, [PromoteAllScalars = true]),
    Schema = Type.TableSchema(Value.Type(Headers)),
    ColumnNames = Schema[Name],
    Required = {"Date", "Amount", "Description"},
    Missing = List.Difference(Required, ColumnNames)
in
    Missing

Missing is the list of required columns that are not in the file. An empty list means the layout is as expected. Each row of Schema also describes the type of its column, so the same check can test types.

Example: a second, different use

Listing the column types of a table so that a reviewer can see which columns are text and which are numbers before a model is built.

Things to watch

In business terms

Schema checks are a good control for recurring files: they catch a new, missing or renamed column before totals go wrong. Save the result as part of the close checklist.

Related functions

All Power Query M functions · View as Markdown · M basics