OpenBI Docs Buy

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> )
ParameterTypeDescription
ExpressionValueThe value to convert.
DatatypeKeywordThe 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. INT rounds down instead.
  • To CURRENCY, the value is rounded to four decimals, as CURRENCY does.
  • 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. To DOUBLE, 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 DOUBLE keeps 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.72.5-2.5INT ( 3.7 )
43-33

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 45658Back to a number0.5 as BOOLEANBlank as BOOLEAN
2025-01-0145658TRUEFALSE

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 CurrencyAs DOUBLE
0.00030.00021

CURRENCY, INT, VALUE, FORMAT, DATATABLE.

Last updated · OpenBI Studio 0.3.74