Type.TableSchema

Updated on

Type.TableSchema is a Power Query M function that returns a table describing the columns of a given table type. The function returns a table with information about the columns in the input table type, as described in the Table.Schema documentation.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Type.TableSchema( tableType as type ) as table
Column NameDescription
NameThe column name.
PositionThe 0-based position of the column in table.
TypeNameThe name of the type of the column.
KindThe kind of the type of the column.
IsNullableWhether the column can contain null values.
NumericPrecisionBaseThe numeric base (for example, base-2 or base-10) of the NumericPrecision and NumericScale fields.
NumericPrecisionThe precision of a numeric column in the base specified by NumericPrecisionBase. This is the maximum number of digits that can be represented by a value of this type (including fractional digits).
NumericScaleThe scale of a numeric column in the base specified by NumericPrecisionBase. This is the number of digits in the fractional part of a value of this type. A value of 0 indicates a fixed scale with no fractional digits. A value of null indicates the scale is not known (either because it is floating or not defined).
DateTimePrecisionThe maximum number of fractional digits supported in the seconds portion of a date or time value.
MaxLengthThe maximum number of characters permitted in a text column, or the maximum number of bytes permitted in a binary column.
IsVariableLengthIndicates whether this column can vary in length (up to MaxLength) or if it is of fixed size.
NativeTypeNameThe name of the type of the column in the native type system of the source (for example, nvarchar for SQL Server).
NativeDefaultExpressionThe default expression for a value of this column in the native expression language of the source (for example, 42 or newid() for SQL Server).
NativeExpression
DescriptionThe description of the column.
IsWritable
FieldCaption

Description

The Type.TableSchema function returns a table describing the columns of the input tableType. It returns similar columns as the Table.Schema function. The operation returns the following fields:

Examples

Suppose you have a table in a step called source. To describe the columns within that table you can make use of the Type.TableSchema function.

You would first need to retrieve what type the table has. With a table called ‘Source’ you can do that by using the Value.Type function:

Value.Type( Source )

You can then pass this abstract table type to the Type.TableSchema function.

Type.TableSchema( Value.Type( Source ) )

This returns a table with 17 columns, describing the contents of your table.

Other functions related to Type.TableSchema are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/type-tableschema