Create Custom Calculations for Your Charts

In SAP Analytics Cloud, you can create custom calculations for your charts such as aggregations, calculated or restricted measures, value-based dimensions, and so on.

When you create calculations for your charts you can include them as either measures or dimensions; the dimension calculations are added as cross calculations. (For information on cross calculations, see Create and Add Structures/Cross Calculations to Charts).

The Calculation Editor is used to create the calculations that can be added to your charts.

Calculation Editor

For each type of calculation, a new calculated or restricted member is created for the dimension that you used to create it. You can also use dimension attributes as part of a calculation. For more information about dimension attributes, see Combine Data with Your Acquired Data.

  1. Type

  2. Name (ID)

  3. Description

  • Type: The type of calculation. For example, Calculated Account, Restricted Account, Difference From, and so on.

  • Name (ID): Mandatory. The name will be used as the ID for the calculation.

    If you don't provide a name, the default text will be used.

  • Description: Optional.

    Calculation descriptions can contain dynamic text in the form of a variable. This variable will update the name displayed in the Story Widget, based in the selected input values. You can reference the following as dynamic text in a description:
    • Calculation input controls

    • Story filters

    • Filter variables

    If the description is not provided, then the ID will be used as the description.

  • While the ID needs to be unique, you can choose to create the same description for multiple calculations.

The following calculation types are supported:

  • Calculated accounts, measures, dimensions, or cross calculations: Perform a calculation on one or more members of either the Account dimension or the Cross Calculations dimension. A new calculated member of the selected dimension is created as a result. See Create Calculated Accounts in Charts or Create and Add Structures/Cross Calculations to Charts.

  • Restricted measures: Restrict the data from a member of either the Account dimension or the Cross Calculations dimension so that it excludes certain members of one or more dimensions. For the Date dimension, you can pick dynamic values such as year-to-date or previous quarter. A new restricted member of the selected dimension is created as a result. (See Create Restricted Accounts in Charts)

  • Difference From: Find the difference in an account's value between two dates. A new calculated account member is created as a result. The Date Difference Calculation also supports timestamps and allows you to calculate the difference down to hours, minutes and seconds. (See Create Difference Calculations in Charts.)

  • Aggregation: Create calculations from aggregations such as sum, count, average, and so on. Choose what conditions are required for the aggregation to be applied, and when the conditions are required. (See Create Aggregation Calculations in Charts.)

  • Date Difference: Calculate the time interval between two dates. (See Calculate the Time Interval Between Two Dates in Charts.)

  • Perform string and number conversions: convert strings to numbers and numbers to strings, and use the resulting values in calculated measures or dimensions. See Convert Strings to Numbers and Numbers to Strings.

  • Dimension to Measure: The string and number conversion functions can be combined with measure-based dimensions to create measure to dimension conversions. (See Dimension to Measure.)

  • Currency conversions: For planning models with currency conversion enabled, add a new currency conversion to the Cross Calculations dimension. For more information, see Display Currencies in Tables.

  • Unit conversions: Unit Conversions are supported in SAP Analytics Cloud Story Calculations. It will convert source values from the base measure to the specified target units, that belong to the same unit group, using values from the standard unit conversion table. Some examples of unit groups include Length, Density and Weight. For more information, see Plan with Currency and Unit Conversion.

Calculations Based on Input Controls

Calculations can use input controls. Input controls provide variable input for a calculation, allowing viewers to influence the result of a calculation without modifying the underlying data or formula. For example, viewers can choose to see the impact of a 1%, 2%, or 3% tax-rate increase. You choose the list of values for an input control, and specify how the user can select values. Input controls can be formatted after they are added to the canvas.

When adding a calculation input control from the calculation editor, you can include a name and description.

  1. Name (ID)

  2. Description

  • Name (ID): Provide a name for your input control. The name will be used as the ID.

  • Description: Provide an optional description.

Duplicate and Edit Calculations

There are times that you may want multiple calculations that are almost the same. For example, you may want restricted measures with different time filters. It takes time to create a calculation and you have to create each calculation separately from start to finish, even if you only need to change one small parameter.

A faster way to create multiple calculations would be to duplicate an existing calculation and then edit it.

  1. Set up the calculation for editing or copying.

    Item

    Duplicate

    Edit

    Select a chart

    1. In the Builder, select a calculation.

    2. Select Start of the navigation path (More) Next navigation step DuplicateEnd of the navigation path.

    1. In the Builder, select a calculation.

    2. Select Start of the navigation path (More) Next navigation step End of the navigation path Edit Calculation.

  2. Make changes to the calculation. (You can't change the calculation type.)

  3. Select OK.

Format a Calculation

You can format the results of a calculation in a chart.

  1. Select a chart.

  2. In the Builder, select a calculation.

  3. Select Start of the navigation path (More) Next navigation step End of the navigation path Format....

  4. Modify the formatting options.

    • Use unit of underlying measures - uses the unit (Dollar, Euro, Yen, and so on) of the underlying measures.

  5. Select OK.

Convert Strings to Numbers and Numbers to Strings

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 Function

ToNumber converts string values to numbers.

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

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

  3. Create your formula.

ToText Function

ToText converts numeric values to strings, and it uses an existing calculated dimension in its calculations.

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

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

  3. Create your formula.

Dimension to Measure

The string and number conversion functions can be combined with Measure-Based dimensions (in a calculated dimension) to create dimension to measure conversions.

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.