CONVERT Function (DAX)

How does the CONVERT function (DAX) work?

The CONVERT function (DAX) converts an expression of one data type to another.

CONVERT Formula Syntax

CONVERT(
     <Expression>, <Datatype>
)

How do you use the CONVERT function?

The CONVERT function returns an error when a value cannot be converted to the specified data type.

Related Blog Posts

Related Support Forum Posts

Convert Rowed Data into Columned Data
Converting currency
Understanding DAX Formula
Developing Complex Dax functions

Considerations when using the CONVERT function

DAX calculated columns must be of a single data type. Since MEDIAN and MEDIANX functions over an integer column return mixed data types, either integer or double, the following calculated column expression will return an error as a result:

MedianNumberCarsOwned = MEDIAN(
DimCustomer[NumberCarsOwned])

To avoid mixed data types, change the expression to always return the double data type, for example:

MedianNumberCarsOwned = MEDIANX(
DimCustomer, CONVERT([NumberCarsOwned], DOUBLE))

Related Video Tutorials

Formula examples using the CONVERT function

SELECT CONVERT(INT, 5.95) result

SELECT CONVERT( CHAR( 20 ), order_date, 104 )

SELECT CONVERT( CHAR( 20 ), order_date, 7 )

Related Course Modules

Ultimate-Beginners-Guide-To-PowerBI

DOWNLOAD

To access our comprehensive DAX formula reference guide just insert your email address below. The resource will download immediately and we’ll also email it to you.