In SAP Analytics Cloud, calculations use formulas to create new measures based on your business data. You can add calculations in the modeling stage by adding formulas to your model, or you can create in-story calculations. In-story calculations create story-specific measures that can be added to any chart within your story.
When setting up in-story calculations you can choose from the following types:
- Calculated Measure
- Restricted Measure
- Difference From
- Date Difference
- Dimension to Measure
The Calculation Editor
To get started with in-story calculations, you’ll want to access the Calculation Editor. This is where you will set up the formulas to create calculations to use within your story.
To open the Calculation Editor select a chart and open the Design Panel. Then, select the ‘New Calculation’ option from the ‘Measures’ drop-down menu.
The Calculated Measures calculation creates a new measure by applying mathematical formulas to your data.
When setting up your calculation, you’ll apply the typical formula functions, conditions, and operators to the data contained in your model. Use calculation shortcuts to access your existing model data.
Type the following characters to access model data to add to your formula:
- [ to access measures
- # to access calculations
- @ to access input controls
For example, to create a calculated measure of gross margin percentage, your formula should divide the measure “gross margin” by the measure “discount”.
Learn more: Creating Calculated Measures
The Restricted Measure calculation creates a new measure by restricting the measure’s value to a selected dimension(s).
For example, you may want to calculate the value of revenue restricted by a single product. By creating a restricted measure, you can compare the revenue performance of a single product type to the whole product dimension in a chart.
There are two ways to determine the value of the restricted measure:
- Select a specific dimension. For example, if your selected dimension is “product” you can restrict the measure by the entire product dimension, or you can choose specific member(s) of that dimension.
- Set up an input control. Input controls allow you to dynamically restrict the measure’s value by different dimensions. In the example below, the value of the restricted measure changes based on the input control selection.
Learn more: Creating Restricted Measures
The Difference From calculation creates a measure reflecting the calculated difference in value between two time periods. Similarly to time-based variances, there are some standard time periods that can be used for your Difference From calculation.
- Period over Period (PoP): Compares a selected time period to the equivalent time period directly prior. For example, selecting a 60-day period will compare to the 60-day period directly prior.
- Year over Year (YoY): Compares to the equivalent period in the year prior. For example, Q1 2017 would compare to Q1 2016.
- Quarter over Quarter (QoQ): Compares to the equivalent period in the previous quarter. For example, Month 1 in Q2 would compare to Month 1 in Q1.
- Month over Month (MoM): Compares to the equivalent period in the previous month. For example, Day 1 in Month 2 would compare to Day 1 in Month 1.
When you create a Difference From calculation, the resulting measure’s value reflects both the calculation and chart properties.
Learn more: Calculating the Difference
The Aggregation calculation creates a measure with an aggregate value such as sum, average, or another aggregation type. To produce aggregate values, SAP Analytics Cloud performs mathematical functions on a measure to return a single value.
The Calculation Editor supports the following aggregation functions:
|Sum||Sum of the measure’s values across all members of the selected dimensions.|
|Count||Number of values of the selected dimensions. Empty values are not counted.|
|Count Dimensions||Number of members of the selected dimensions, regardless of whether their values are empty or not.|
|Average||Average of the measure’s values across the selected dimensions.|
|Min||Smallest value across the selected dimensions.|
|Max||Largest value across the selected dimensions.|
Watch the video below for a step-by-step example of how to set up an in-story aggregation calculation.
Learn more: Creating an Aggregation
The Date Difference calculation creates a calculation that shows the time interval between two dates. To use this, your model must have date columns or date (time) hierarchies with day level granularity.
Learn more: Calculating the Time Interval Between Two Dates
Dimension to Measure
The Dimension to Measure calculation allows you to convert a string value (text) to a numeric value which can then be used to perform measure based calculations. For example, if we have dimension values with number part and a $ sign, we can remove $ from the dimension and convert the number part as a measure using this function.