Table of contents
TOC
Collapse the table of content
Expand the table of content

Type conversion

Owen Duncan|Last Updated: 4/19/2018

The Power Query M formula language has formulas to convert between types. The following is a summary of conversion formulas in M.

Number

Type conversionDescription
Number.FromText(text as text) as numberReturns a number value from a text value.
Number.ToText(number as number) as textReturns a text value from a number value.
Number.From(value as any) as numberReturns a number value from a value.
Int32.From(value as any) as numberReturns a 32-bit integer number value from the given value.
Int64.From(value as any) as numberReturns a 64-bit integer number value from the given value.
Single.From(value as any) as numberReturns a Single number value from the given value.
Double.From(value as any) as numberReturns a Double number value from the given value.
Decimal.From(value as any) as numberReturns a Decimal number value from the given value.
Currency.From(value as any) as numberReturns a Currency number value from the given value.

Text

Type conversionDescription
Text.From(value as any) as textReturns the text representation of a number, date, time, datetime, datetimezone, logical, duration or binary value.

Logical

Type conversionDescription
Logical.FromText(text as text) as logicalReturns a logical value of true or false from a text value.
Logical.ToText(logical as logical) as textReturns a text value from a logical value.
Logical.From(value as any) as logicalReturns a logical value from a value.

Date, Time, DateTime, and DateTimeZone

Type conversionDescription
.FromText(text as text) as date, time, datetime, or datetimezoneReturns a date, time, datetime, or datetimezone value from a set of date formats and culture value.
.ToText(date, time, dateTime, or dateTimeZone as
date, time, datetime, or datetimezone) as text
Returns a text value from a date, time, datetime, or datetimezone value.
.From(value as any)Returns a date, time, datetime, or datetimezone value from a value.
.ToRecord(date, time, dateTime, or dateTimeZone as date, time, datetime, or datetimezone)Returns a record containing parts of a date, time, datetime, or datetimezone value.
© 2018 Microsoft