Convert and Calculate: Strings to Numbers and Numbers to Strings

In SAP Analytics Cloud, convert a string value to a numeric value or a numeric value to a string value and use the new values in calculated dimensions or measures.

There are two functions that you can use to convert values from one type to another in calculated measures or calculated dimensions: ToNumber and ToText.
  • ToNumber converts string values to numbers

  • ToText converts numeric values to strings

    ToText uses an existing calculated dimension in its calculations.

ToNumber Function
  1. In Builder, under Dimensions, select Start of the navigation pathAdd Dimension Next navigation step Calculated DimensionsEnd of the navigation path.

  2. In the Calculation Editor under Type, select Calculated Dimension.

  3. Create your formula.

    Example
    ToNumber ([d/ACT_EMPLOYEE_NUMERIC:Age_String].[p/ID])
ToText Function

ToText requires an existing calculated dimension.

  1. In Builder, under Dimensions, select Start of the navigation pathAdd Dimension Next navigation step Calculated DimensionsEnd of the navigation path.

  2. In the Calculation Editor under Type, select Calculated Dimension.

  3. Create your formula.

    Example
    ToText (<ToNumber calculated dimension> ) + " years"
Dimension to Measure

The string and number conversion functions can be combined with Measure-Based dimensions (in a calculated dimension) to create measure to dimension conversions. For more information about Measure-Based dimensions, see Create Measure-Based Dimensions.

There is also a calculation type that lets you convert a dimension to a measure.

  1. Add a chart to the canvas.

  2. In Builder, choose Start of the navigation pathAdd Measure Next navigation step Create Calculation Next navigation step Dimension To MeasureEnd of the navigation path.

  3. From Dimension Attribute to Convert, select a dimension.

  4. Select context dimensions.

  5. Set the aggregation operation type.

  6. Select OK and review the results in the chart.