Building Advanced Formula Data Actions
Building Advanced Formula Data Actions
Learning
/ Browse / Learning Journeys / Leveraging SAP Analytics Cloud Functionality for Enterprise Planning / Buildin…
Actions
Configuring Data Actions
Objectives
Configuring Data Actions
After completing this lesson, you will be able to:
57 mins
Build advanced formula data actions
Building Advanced Formula Data
Actions
59 mins
Maintenance:
Allocating Planning Data
The script editor provides context help and code completion
Validation and trace mode in the script editor
Features:
Translating Currencies for Planning
The visual editor provides a graphical wizard to define calculation logic
The statements are represented by boxes, which can be further configured with special
Forecasting and Simulating Planning
dialogs
Data The graphical representations give users a clear logic flow
https://learning.sap.com/learning-journeys/leveraging-sap-analytics-cloud-functionality-for-enterprise-planning/building-advanced-formula-data-a… 1/15
10/07/2024 09:56 Building Advanced Formula Data Actions
Learning
/ Browse / Learning Journeys / Leveraging SAP Analytics Cloud Functionality for Enterprise Planning / Buildin…
Note
Advanced data actions are used to perform calculations that are stored in the database. If
there's a need to perform calculations that aren't stored in the database, there are several
options:
Data table formulas
Story-based calculated measures
Model-based calculated measures
Calculation
Repeat
Condition
Delete
Comments
https://learning.sap.com/learning-journeys/leveraging-sap-analytics-cloud-functionality-for-enterprise-planning/building-advanced-formula-data-a… 2/15
10/07/2024 09:56 Building Advanced Formula Data Actions
Learning
/ Browse / Learning Journeys / Leveraging SAP Analytics Cloud Functionality for Enterprise Planning / Buildin…
Advanced Formula
Advanced formula actions allow 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 "on the fly", the advanced
formulas data action 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.
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.
You can hover on a dimension in the data line to see what members are included in the scope of
the Calculation.
https://learning.sap.com/learning-journeys/leveraging-sap-analytics-cloud-functionality-for-enterprise-planning/building-advanced-formula-data-a… 3/15
10/07/2024 09:56 Building Advanced Formula Data Actions
Learning
/ Browse / Learning Journeys / Leveraging SAP Analytics Cloud Functionality for Enterprise Planning / Buildin…
You can build your own logic in the visual editor and then view the generated code in the script
editor.
https://learning.sap.com/learning-journeys/leveraging-sap-analytics-cloud-functionality-for-enterprise-planning/building-advanced-formula-data-a… 4/15
10/07/2024 09:56 Building Advanced Formula Data Actions
Learning
Visual Editor Script Editor
Context Membersets
Memberset is used to determine the context, that is the Point of View or the Scope.
The time hierarchy is set to the Calendar Year, therefore YQM is the hierarchy ID.
% denotes variables: for example %YearMonth% refers to the prompt/variable for time.
Result: If you select 2021, the system will include all months of 2021 in the calculation.
The H1 hierarchy for the cost center dimension has been selected.
Learning
All_Cost_Centers is the id of the top node/parent.
Result, if the user selects hierarchy node Canada, only Canadian cost centers will be included in
/ Browse / the
Learning Journeys / Leveraging SAP Analytics Cloud Functionality for Enterprise Planning / Buildin…
calculation.
In the preceding example, January data is being copied to February with an uplift:
In this example, %TargetMonthYr% is the receiver or target that is dynamically selected by the
planner.
RESULTLOOKUP([d/Date]=PREVIOUS(1)) dynamically reads the previous month (or period) as
compared to the %TargetMonthYr% selection.
%UpLift% is the variable for the uplift provided by the planner. Example: 1.25.
Before Jen can run the data action to perform the calculation, you must use the visual editor to
create a data action that calculates labor. Since labor rates are in the HR model, you will use the
link command to look-up the labor rates and calculate labor.
EXERCISE
/ Browse / Learning Journeys / Leveraging SAP Analytics Cloud Functionality for Enterprise Planning / Buildin…
Start Exercise
Variables
Variables in advanced formulas can be used to store data temporarily while the script is running, to
avoid calculating the value repeatedly. This is the traditional concept referred to as a Local
Variable. or Virtual Variable Member. The virtual variable member will be stored independently
and cannot be added to a dimension like a real dimension member. After defining a variable
member for a certain dimension, you can use the variable member to store values only for that
specific dimension.
Key Points:
Write this definition after the configuration settings and before all the instructions.
Create a new name for a virtual variable member. Make sure, in the variable member definition,
it always starts with the prefix "#".
Dimension Name is mandatory and must be an existing dimension in the current data action
model. The version dimension is not supported. Measures are supported, for example:
VARIABLEMEMBER #Total_Revenue OF [d/Measures]
A virtual variable member can only be used in DATA and RESULTLOOKUP functions. When
inputting "#" in DATA() or RESULTLOOKUP(), a list of all available virtual members will be shown.
In the following example of advanced logic virtual variables, you can see that:
https://learning.sap.com/learning-journeys/leveraging-sap-analytics-cloud-functionality-for-enterprise-planning/building-advanced-formula-data-a… 7/15
10/07/2024 09:56 Building Advanced Formula Data Actions
Configuration Options
Learning
/ Browse / Learning Journeys / Leveraging SAP Analytics Cloud Functionality for Enterprise Planning / Buildin…
Configuration Options
Fiscal Year: This configuration governs the time hierarchy used in the advanced formulas.
This setting affects the result of time/date commands, such as FIRST and LAST.It controls
which period is selected.
Account Sign Flip: If this option is turned on, all calculations consider the sign value (debit
or credit) of each account according to the account type (LEQ, AST, INC, and EXP).
Unbooked Data: Unbooked data refers to cells with empty values. If turned on, all empty
cells in the source data to be copied will be treated as cells with zeroes.
This configuration governs the time hierarchy of the script. If this configuration is not defined, the
default time hierarchy from the model is used.
In the following example, the memberset command is selecting data for revenue and cost and
then writing the result to retained earnings. If the sign flip setting is ON, the correct value (40) is
written to retained earnings.
https://learning.sap.com/learning-journeys/leveraging-sap-analytics-cloud-functionality-for-enterprise-planning/building-advanced-formula-data-a… 8/15
10/07/2024 09:56 Building Advanced Formula Data Actions
Learning
/ Browse / Learning Journeys / Leveraging SAP Analytics Cloud Functionality for Enterprise Planning / Buildin…
Auto Complete
As you type, a hint list shows all available functions that match the text you've typed. A short help
text description is available for each function. You can use Ctrl+Space to choose from a list of
values that are valid for that location in the formula, or type [d/ for a list of valid dimensions and
properties to use in the formula.
https://learning.sap.com/learning-journeys/leveraging-sap-analytics-cloud-functionality-for-enterprise-planning/building-advanced-formula-data-a… 9/15
10/07/2024 09:56 Building Advanced Formula Data Actions
There are also formula templates for common calculations. If you select a formula from the hint
Learning
list, a template is automatically entered in the formula entry bar.
Script Syntax
[ ]: Dimensions, properties, hierarchies are enclosed in square brackets
d: Dimension. Example: [d/Cost_Center]
p: Property. Example: [d/Account].[p/ElimTarget]
h: Hierarchy. Example: [d/Cost_Center].[h/H1], "All_Cost_Centers"))
%: Variables. Example: % YearMonth%
#: Unassigned. Example: since labor hours aren’t currency related, currency is
unassigned:RESULTLOOKUP([d/Account] = "LHours", [d/Currency] = "#")
" ": Double quotes are required when specifying dimension members.
/: Comments
Note
In an advanced formulas step, you can repeat a group of statements a specified number of
times, using the FOR keyword. Employing a BREAK statement inside a FOR loop will allow
you to stop the loop when the given condition is met, offering more flexibility.
Note
In the Show option in the Script tab, you can turn Auto Complete off.
For more syntax options, to the reference guide: Advanced Formulas Reference Guide
https://learning.sap.com/learning-journeys/leveraging-sap-analytics-cloud-functionality-for-enterprise-planning/building-advanced-formula-data-… 10/15
10/07/2024 09:56 Building Advanced Formula Data Actions
Formula Options
Learning
/ Browse / Learning Journeys / Leveraging SAP Analytics Cloud Functionality for Enterprise Planning / Buildin…
Formula Options
When you create an advanced formula, you have 5 options.
2. Delete will prompt for a filter upon which to identify which cost center to delete, for example.
3. Repeat (loop) will prompt for a dimension to loop over, and then you can add a calculation, for
example.
For example, calculate revenue amount with a 10% increase over the previous month:
1
2 MEMBERSET [d/Date] = (BASEMEMBER([d/Date].[h/YQM], "[2024]"))
3 MEMBERSET [d/Measures] = ("Amount")
4 MEMBERSET [d/Account] = ("Revenue")
5 FOREACH [d/Date]
https://learning.sap.com/learning-journeys/leveraging-sap-analytics-cloud-functionality-for-enterprise-planning/building-advanced-formula-data-… 11/15
10/07/2024 09:56 Building Advanced Formula Data Actions
/ Browse / Learning Journeys / Leveraging SAP Analytics Cloud Functionality for Enterprise Planning / Buildin…
4. Comment creates an input field for explanations.
5. Condition will prompt for a filter upon which to create the if statement, and then you can add a
calculation.
For example, if the company = US, then copy prior year data to the current year data +10%.
1
2 MEMBERSET [d/Date] = (BASEMEMBER([d/Date].[h/YQM], "[2024]"))
3 MEMBERSET [d/Measures] = ("Amount")
4 MEMBERSET [d/Account] = ("Revenue")
5 IF [d/Company] = "US" THEN
6 DATA() = RESULTLOOKUP([d/Date] = Previous(12)) * 1.1
7 ENDIF
In the previous examples, you can see how the system creates formulas depending on which
option you pick. Each one generates code that you can view in the script dialog. In the following
example, you can see an example of a Calculate Labor formula in the Visual Editor.
https://learning.sap.com/learning-journeys/leveraging-sap-analytics-cloud-functionality-for-enterprise-planning/building-advanced-formula-data-… 12/15
10/07/2024 09:56 Building Advanced Formula Data Actions
Learning
/ Browse / Learning Journeys / Leveraging SAP Analytics Cloud Functionality for Enterprise Planning / Buildin…
Editing Options
There are four editing options, when you hover over the formula:
1. Duplicate
2. Annotate
3. Comment out
4. Delete
1. Each line of instruction inherits the calculation results of previous lines of instructions.
2. Advanced formulas perform all calculations only with leaf-level members that don’t have any
account formulas defined.
3. In a RESULTLOOKUP function, the function considers the most detailed values in the dataset,
even if the formula doesn't specify them. For example, consider the following record set:
Sparkling
Quantity Germany Dec.2018 50
Water
Sparkling
Quantity France Dec.2018 70
Water
Sparkling
Quantity UK Dec.2018 90
Water
You write a formula to add 20 to the Quantity Values for December 2018 and write the new
values to January 2019:
https://learning.sap.com/learning-journeys/leveraging-sap-analytics-cloud-functionality-for-enterprise-planning/building-advanced-formula-data-… 13/15
10/07/2024 09:56 Building Advanced Formula Data Actions
The final result will add 20 to each detailed Entity value, not to the aggregated Region value:
Learning
Sparkling
Quantity Germany Jan.2019 70
Water
Sparkling
Quantity France Jan.2019 90
Water
Sparkling
Quantity UK Jan.2019 110
Water
4. A null value is treated as a non-existent value, while 0 is treated as an actual number. If the
RESULTLOOKUP function returns a null value, advanced formulas do nothing.
5. Advanced formulas basically work with the fact record-set of the model. If you don't specify
other dimension information and members via the MEMBERSET definition, the advanced
formulas will take all members from the dimensions in the model.
Note
In an advanced formulas step, you can repeat a group of statements a specified number of
times, using the FOR keyword. Employing a BREAK statement inside a FOR loop will allow
you to stop the loop when the given condition is met, offering more flexibility.
https://learning.sap.com/learning-journeys/leveraging-sap-analytics-cloud-functionality-for-enterprise-planning/building-advanced-formula-data-… 14/15
10/07/2024 09:56 Building Advanced Formula Data Actions
Legal Disclosure SAP Developer Center Trademark Frequently Asked
Learning Questions
Cookie Preferences SAP Community Worldwide Directory
Do not share/sell
/ Browse my
/ Learning SAP Learning
Journeys Hub SAP Analytics
/ Leveraging Careers
Cloud Functionality for Enterprise Planning / Buildin…
personal information (US
Learners only) SAP Training Shop News and Press
Newsletter
Find us on:
Business Scenario
You are a member of the planning team at ABC Corporation and you are responsible for creating
and configuring data actions.
Before Jen can run the data action, you must create and test an advanced formula data action
using the visual editor as well as the script editor. The benefits rate will be entered when Jen runs
the data action.
EXERCISE
Start Exercise
Next lesson
https://learning.sap.com/learning-journeys/leveraging-sap-analytics-cloud-functionality-for-enterprise-planning/building-advanced-formula-data-… 15/15