Table.Schema
A table that describes a table's columns: a row per column with its name, place, type and whether it takes null.
Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Table.Schema(table as table) as table
| Parameter | Type | Description |
|---|---|---|
table | table | The table to describe. |
Returns
table. A row per column, with Power Query's 19 columns describing it: first Name, Position (from 0), TypeName, Kind and IsNullable.
Remarks
- TypeName is the type's name as M writes it (Text.Type, Int64.Type); Kind is the kind of value behind it (text, number).
- A column without a type has Kind any, and IsNullable is true.
- The other 14 columns (NumericPrecision, MaxLength, NativeTypeName, Description and the rest) describe a database column; they are null for a table made in M.
Examples
The columns of a typed table
The example keeps the five columns this page describes.
let
Products = #table(type table [Product = text, Price = nullable number, Units = Int64.Type, Note = any], {})
in
Table.SelectColumns(Table.Schema(Products), {"Name", "Position", "TypeName", "Kind", "IsNullable"})
| Name | Position | TypeName | Kind | IsNullable |
|---|---|---|---|---|
| Product | 0 | Text.Type | text | false |
| Price | 1 | Number.Type | number | true |
| Units | 2 | Int64.Type | number | false |
| Note | 3 | Any.Type | any | true |
Related functions
Table.ColumnNames, Table.ColumnsOfType, Table.TransformColumnTypes, Value.Type.