Type.TableSchema
Returns a table that describes the columns of a table type: their names and their types.
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
tableType: a table type, usuallyValue.Type(table)for a table you already have.
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
- The schema table has its own column names. Read the Name column for the column names, and check the rest of the columns in the editor the first time you use it.
- A schema is a type, so it describes what the table claims to be. If a column is typed as text, values are still text.
- Use it on the result of Value.Type, not on the table itself.
- For a simpler test, Table.ColumnNames and List.Difference give the same missing-column result.
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.