Downloads
Power Query MLanguageIntermediate

type

Names a type, such as number, text or date, so you can tell Power Query what a value or column holds.

Syntax
type typeExpression

Returns: A type value, which Power Query uses in type steps and in function arguments.

What it does

The type keyword writes a type. You use it in a step that sets column types, such as Table.TransformColumnTypes, and as the third argument to Table.AddColumn, so that the new column is typed when it is created. Types also appear after as in a function's arguments. Setting types is a basic habit: it makes the query fail early when data is wrong, instead of later.

Syntax and arguments

Example

A bank export has text for the date and amount. The query sets the types once, near the end, so that the amounts add up and the dates sort.

let
    Source = Table.FromRecords({
        [Date = "2026-03-31", Amount = "1250", Memo = "Rent"],
        [Date = "2026-03-31", Amount = "480", Memo = "Supplies"]
    }),
    Typed = Table.TransformColumnTypes(Source, {
        {"Date", type date},
        {"Amount", type number}
    }),
    WithFlag = Table.AddColumn(Typed, "Large", each [Amount] >= 1000, type logical)
in
    WithFlag

After the type step, Amount is a number, so List.Sum and sorting work, and Date is a real date. The new Large column is typed as logical when it is created.

Example: a second, different use

Declaring a function argument as optional and nullable: (rate as nullable number) as number => rate ?? 1 accepts a null rate and uses 1 in its place.

Things to watch

In business terms

Typed columns are the difference between a total that works and one that quietly adds text. A type step is also a small piece of documentation: it states that the amount is a number and the date is a date.

Related functions

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