Create Custom Calculations for Your Charts
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 Add 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.
-
Choosing a number format that uses periods (.) as decimal separators means that commas (,) must be used to separate function parameters (for example, IF(Condition, ValueIfConditionIsTrue, ValueIfConditionIsFalse)).
-
Choosing a number format that uses commas (,) as decimal separators means that semi-colons (;) must be used to separate function parameters (for example, IF(Condition; ValueIfConditionIsTrue; ValueIfConditionIsFalse)).
If the formula is typed in from scratch, the correct function auto-completion happens based on the user preferences. However, if you copy and paste a full formula string, auto-complete won't be able to adapt if there is a mismatch between separators used and the user preferences.
In a chart, calculations based on the Account dimension can be added as new measures.
The following calculation types are supported:
-
Calculated measures: 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 Measures for Charts
RestrictionIf the calculation is based on the Cross Calculations dimension then dimension members or attributes from the Account dimension cannot be used.
If the calculation is based on the Account dimension then dimension members from the Cross Calculations dimension cannot be used.
-
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 Measures for Charts) .
NoteWhen using data from SAP BW, creating a restricted measure on another restricted measure (referred to as a key figure in SAP BW) that uses the same dimension results in incorrect data in SAP Analytics Cloud. A further restriction is not possible because SAP BW treats restrictions as OR operations. In most cases restricted measures are intended to get the result as an AND operation.
For example, COUNTRY is restricted to Great Britain and Germany. In a sales scenario, the intended result would be that you see products that are sold in both countries (Great Britain OR Germany) and not a combination of either country and both of them (Great Britain OR Germany OR (Great Britain AND Germany)).
-
Difference From: Find the difference in an account’s value between two dates. A new calculated account member is created as a result. (See Calculate the Difference for 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 Aggregations for Charts)
- Date Difference: Calculate the time interval between two dates. (See Calculate the Time Interval Between Two Dates)
-
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 Create Calculated Dimensions for Charts, How to Create a Measure-Based Dimension, and Dimension to Measure.)
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.
You can add dynamic time calculations directly to a chart. For more information, see Dynamically Add a Time Calculation.
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.
- Calculated measures
- Restricted measures
- Calculated dimensions
- Cross calculations
- Set up the calculation for editing or copying.
Item Duplicate Edit Select a chart - In the Builder, select a calculation.
- Select .
- In the Builder, select a calculation.
- Select .
-
Make changes to the calculation. (You can't change the calculation type.)
-
Select OK.
Format a Calculation
You can format the results of a calculation in a chart.
- Select a chart.
-
In the Builder, select a calculation.
-
Select
. -
Modify the formatting options.
-
Use unit of underlying measures - uses the unit (Dollar, Euro, Yen, and so on) of the underlying measures.
-
-
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.
-
In Builder, under Dimensions, select .
-
In the Calculation Editor under Type, select Calculated Dimension.
-
Create your formula.
ExampleToNumber ([d/ACT_EMPLOYEE_NUMERIC:Age_String].[p/ID])
ToText Function
ToText converts numeric values to strings, and it uses an existing calculated dimension in its calculations.
-
In Builder, under Dimensions, select .
-
In the Calculation Editor under Type, select Calculated Dimension.
-
Create your formula.
ExampleToText (<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 dimension to measure conversions. For more information about Measure-Based dimensions, see How to Create a Measure-Based Dimension.
There is also a calculation type that lets you convert a dimension to a measure.
-
Add a chart to the canvas.
-
In Builder, choose .
-
From Dimension Attribute to Convert, select a dimension.
-
Select context dimensions.
-
Set the aggregation operation type.
-
Select OK and review the results in the chart.