Planning requires various types of calculations. An advanced formula step in a data action allows you to design formulas for calculations to apply to the source data. The results are written to specified scopes in the planning model.
Unlike dimension formulas, which perform the calculation in real-time, a data action with an advanced formulas step stores the result of the calculation in the SAP Analytics Cloud database. And, as with dimension formulas, parameters can be used in the advanced formula data action.
If there's a need to perform calculations that aren't stored in the database, there are several options that you can use:
- Data table formulas.
- Story-based calculated measures.
- Model-based calculated measures.
When should you consider a data action with an advanced formulas step? Some use cases include:
- When custom calculation logic is required.
- For driver-based formulas such as Revenue = Price x Quantity.
- For depreciation calculations.
- To populate opening balances for headcounts.
- For mark-ups and mark-downs.
- When they need to be scheduled or run on an ad-hoc basis.
Key features of advanced formula steps include:
- Support AND/OR for IF condition: Complex and detailed condition expressions are possible with shorter scripts, which means better execution performance time as well as better readability.
- Keyword BREAK that stops a loop if a specific condition is fulfilled: Support an immediate stop of FOREACH loop with IF condition or others. For example, stopping the depreciation loop with date dimension is possible if the residual book value reaches zero value or the iteration number reaches and the same as the useful life. You don't need to loop for an entire date scope resulting in better execution performance.
- Load pre-aggregated value as calculation scope: Minimize the dataset size of calculation scope for non-calculation related dimensions.
- Pop-up dialog-box that shows the calculation scope: Estimate the calculation scope at design time and optimize the script for better execution performance.
Generate Advanced Formulas
There are two ways to generate scripts in a data action that contains a advanced formulas step:
- The visual editor is graphical wizard to define calculation logic in a flow diagram. The statements are represented by boxes, which can be further configured with special dialogs, giving a clear visual logic flow. Simple scripts are generated that are based on the visual build and can be viewed by clicking Script.
- The script editor provides context help and code completion and includes validation and trace mode. It is used for more complex programming.

In summary:
| Visual Editor | Script Editor |
|---|---|
| Target: Business users | Target: Professional modeling users, such as IT specialists |
| No coding skills required | Requires basic coding knowledge |
| Created by using graphic elements to create a flow | Created by writing scripts |
| Can be switched to script | Can be switched back to the visual editor |
Create Calculations with the Visual Editor
In this lesson, we focus on the visual editor as a way to create advanced formulas. We will use the visual editor to create a simple calculation to calculate labor hours. In the next lesson, we take a more in-depth look at variables, configuration options, formula options, and script syntax.

In the visual editor, you can:
- Specify the context.
- Add a variable, if required.
- Set any required configuration options.
- Time hierarchy - fiscal year or calendar year
- Signflip - on or off
- Unbooked - on or off
- Choose the required formula option.
- Calculation
- Repeat
- Condition
- Delete
- Comment


