CONVERT

Updated on

CONVERT is a DAX function that converts an expression to a specified data type.

Syntax

CONVERT(
   Expression,
   DataType
)
Argument Properties Description
Expression An expression which needs to be converted.
DataType An enumeration that includes: INTEGER, DOUBLE, STRING, BOOLEAN, CURRENCY, DATETIME.

Return Values

Returns the value of Expression, translated to Datatype.

Remarks

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

  • 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)).

  • This function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.

Example

DAX query

EVALUATE { CONVERT(DATE(1900, 1, 1), INTEGER) }

Returns

[Value]
2

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/dax/convert-function-dax

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy