All eazyBI for Jira eazyBI for Confluence Private eazyBI

Cast

The Cast operator converts scalar expressions to other types.

Syntax

Cast(<Value_Expression> AS <Type>)


Arguments

Value_Expression

MDX Expression that contains a numeric, string, boolean, or date value.

Type

The type the expression needs to convert to - BOOLEAN, NUMERIC, INTEGER, or STRING.

Examples

Convert numeric to string type value

This example will convert the numeric value of the measure "Hours spent" to a string type, which will then be concatenated with a custom text.

Cast(
  CoalesceEmpty(
    [Measures].[Hours spent],
    0
  ) 
  AS STRING
) 
|| 
" hours logged"

This will return a string value "45.0 hours logged" for a row that has a value of "45" for the "Hours spent" measure.

To get the rounded values, you can additionally cast the measure as an INTEGER before casting it as STRING:

Cast(
  Cast(
    CoalesceEmpty(
      [Measures].[Hours spent],
      0
    )
    AS INTEGER
  )
  AS STRING
)
|| 
" hours logged"

This will return a string value "45 hours logged" for a row with a value "45" for the "Hours spent" measure.

See also

  • Function CoalesceEmpty() to replace empty values with an alternative value.