CONVERT
A value converted to a type: BOOLEAN, CURRENCY, DATETIME, DOUBLE, INTEGER or STRING; text that isn't that type is an error.
Group: Math. Compatible with DAX.
Syntax
CONVERT ( <Expression>, <Datatype> )
| Parameter | Type | Description |
|---|---|---|
Expression | Value | The value to convert. |
Datatype | Keyword | The type to convert to: BOOLEAN, CURRENCY, DATETIME, DOUBLE, INTEGER or STRING. |
Returns
The type asked for. The value as a value of that type.
Remarks
- To
INTEGER, a number is rounded to the nearest whole number, a half away from zero: 3.7 gives 4, 2.5 gives 3 and -2.5 gives -3.INTrounds down instead. - To
CURRENCY, the value is rounded to four decimals, asCURRENCYdoes. - To
BOOLEAN, 0 is FALSE and any other number TRUE; the texts "TRUE" and "FALSE" are read as such. - To
DATETIME, a number counts days since 30 December 1899, with the time of day in its decimals: 45658 is 1 January 2025. ToDOUBLE, a date gives that number back. - A blank stays blank, except to
BOOLEAN, where it becomes FALSE. - Text that is no value of the type, such as "abc" to
INTEGER, is an error; so is a number too large for the type. - Converting a Currency value to
DOUBLEkeeps the digits past the fourth decimal in what follows.
Examples
Rounding to INTEGER
CONVERT rounds where INT goes down.
EVALUATE
ROW (
"3.7", CONVERT ( 3.7, INTEGER ),
"2.5", CONVERT ( 2.5, INTEGER ),
"-2.5", CONVERT ( -2.5, INTEGER ),
"INT ( 3.7 )", INT ( 3.7 )
)
| 3.7 | 2.5 | -2.5 | INT ( 3.7 ) |
|---|---|---|---|
| 4 | 3 | -3 | 3 |
Dates, numbers and TRUE/FALSE
EVALUATE
ROW (
"Day 45658", CONVERT ( 45658, DATETIME ),
"Back to a number", CONVERT ( DATE ( 2025, 1, 1 ), DOUBLE ),
"0.5 as BOOLEAN", CONVERT ( 0.5, BOOLEAN ),
"Blank as BOOLEAN", CONVERT ( BLANK (), BOOLEAN )
)
| Day 45658 | Back to a number | 0.5 as BOOLEAN | Blank as BOOLEAN |
|---|---|---|---|
| 2025-01-01 | 45658 | TRUE | FALSE |
Keeping the small digits of a Currency
As a Currency, each row is rounded to four decimals; as a DOUBLE, nothing is.
EVALUATE
VAR Items =
DATATABLE ( "Item", STRING, "Price", CURRENCY, { { "a", 1 }, { "b", 1 }, { "c", 1 } } )
RETURN
ROW (
"As Currency", SUMX ( Items, [Price] * 0.00007 ),
"As DOUBLE", SUMX ( Items, CONVERT ( [Price], DOUBLE ) * 0.00007 )
)
| As Currency | As DOUBLE |
|---|---|
| 0.0003 | 0.00021 |