Objective
In this lesson, we will create a Sales Analytic Model and prepare it for analytic consumption. We specify the measures and dimension attributes of the Sales Fact, and associated Business Partner and Product dimensions.
Based on this initial specification, we define different types of measures, like calculated or restricted business measures. Additionally, an input variable and a filter variable are created. The input values can be changed dynamically in the analytics use case.
At the conclusion of this lesson your Analytic Model will look like:

Review the Help Portal for more information at Creating an Analytic Model.
There are two options to create a new Analytic Model. Either inside the Fact view editor using the Create Analytic Model link in the properties side panel. Or from scratch, which we will perform in the following steps.
Select Data Builder in the side navigation area. Choose your space if necessary.
Select New Analytic Model, opening the editor.

In the Repository section, search for your Sales Fact.
Drag Sales Fact and drop it on the canvas.
Note: If you did not create the fact view Sales Fact in the previous unit, choose the predefined, shared object 4OV_Sales Fact instead.

In the pop-up window, all measures, attributes and associated dimensions are marked by default. To add these to the Analytic Model, choose the Select button.

[Optional] Press the Show or hide source tree icon to hide the soure tree explorer, and then the Reset button to align the model to the enlarged canvas area.

The Analytic Model, along with its fact source and linked dimension nodes, is displayed on the canvas.
In the properties side panel, the measures and dimensions are listed, that are exposed for analytic consumption. Here we see:

In the properties side panel, enter Sales Analytic Model as the Analytic Model name.

By selecting the fact and dimension nodes on the canvas, their properties are displayed in the side panel. You can add or remove their measures, attributes, as well as dimension associations anytime. This way, modelers can carefully design what parts of the data model to expose for a given analytic use case.
In the next steps, we remove several not required measures and attributes of the fact and the dimension entities, to streamline our analytic model.
Select Sales Fact from the Fact Sources node on the canvas.
In the properties side panel,
Unselect the measures:
Unselect the attributes:

In the properties side panel, unselect the attributes:

In the properties side panel, unselect the attributes:
In the properties side panel, select the right chevron symbol of ADDRESSID to edit the attribute.


Select the ADDRESSID (Address Dimension) node on the canvas and apply following settings in the properties side panel:

Select the CEATEDATE (Time Dimension - Day) node on the canvas.
In the properties panel, only rename the Business Name CREATEDAT to OrderCreationDate.

The diagram and the properties of the Analytic Model should look like below. The dimensions belonging to the first, second and third level on the canvas are in the properties overview arranged on the same level, aligning to SAP Analytics Cloud standard.

Let’s save the analytic model before proceeding with the creation of new measures and variables.
Select the Save icon in the header menu and confirm the name Sales Analytic Model in the dialog popup.

Much more complex measures can be defined via Analytic Model functionalities. The following types of measures can be added:
A calculated measure references other measures (which are calculated and aggregated at first) and allows the combination of measures. Let’s add a measure to calculate the average price, based on the gross amount and quantity values.

Validate the expression.

Select the Sales Analytic Model link to return to the main panel overview.

A restricted measure variable is used in the filter condition of a restricted measure. Let’s add a variable to ask for the domestic country. The variable is assigned to the restricted measure calculations afterwards.
Go to Variables section in the properties panel.
Select the Add Variable ‘+’ button and choose Restriction Variable.

For the new variable, fill in the following values:
Business Name: Which Domestic Country
Dimension: COUNTRY (ADDRESSID)
Filter Type: Single Value
Default Value: DE
Mandatory: [Set Flag]

The variable shows an error as it is not assigned to a restricted measure yet, we will do that next.
Let’s now create restricted measures. Measures that build on existing measures but restrict them along a filter. This is typically used for comparing values by status, like comparing the value of all orders with the value of all open orders. Here we’ll define a Gross Sales measure for the choosen domestic country, to get a better insight. Optionally, define a second restricte measure, representing the international gross sales.
In the measures section, select the Add Measure ‘+’ button and choose Restricted Measure.
For the new restricted measure, enter the following properties.
Business Name: Domestic Gross Sales
Source Measure: GROSSAMOUNT
Expression: COUNTRY_ADDRESSID = :WHICH_DOMESTIC_COUNTRY
Note: The restricted measure will use the restricted measure variable WHICH_COUNTRY in the expression.
Validate the expression:
Expression: COUNTRY_ADDRESSID = :WHICH_DOMESTIC_COUNTRY
Note: If the message Dimension cannot be found appears, verify the correct dimension entry in the Dimensions (34) attribute list.

Select the Sales Analytic Model link, to return to the main overview.
Optionally, repeat the last step and create a second restricted measure, calculating the value of the international gross sales. Enter the following values:
A count distinct measure counts unique occurrences of attributes. We are interested in the average spend per customer (business partner). For this purpose, we count individual partners in the current drill-down and use that to calculate their average spend amount. The count distinct measure serves as auxiliary measure for the other measure and therefore not exposed for analytic purpose.
In the measures section, select the Add Measure ‘+’ button and choose Count Distinct Measure.

Select the Sales Analytic Model link to return to the main panel overview.
In the measures section, select the Add Measure ‘+’ button and choose Calculated Measure.
For the new measure, enter the following properties:

The Analytic Model enables the creation of Exception Aggregation, expressing complex sub- selection and aggregation behaviours, known from SAP Business Warehouse.
Exception Aggregation are the exception from the rule, which is the default aggregation behaviour defined for the measure. It is even applied when the dimension is not selected in the drill-down.
Let us count the products whose gross amount is exceeding the value of 10 million, to assess how many “high value” products are part of an analytics query, like for a sales order drill-down.
In the measures section, select the Add Measure ‘+’ button and choose Calculated Measure.
For the new measure, enter following the values:
Validate the expression.

Collapse the expression section or scroll down to Exception Aggregation.
Select the following exception aggregation values:
Type: SUM
Dimension: PRODUCTID (Sales Fact)

Finally, we create a filter variable, which specifies a year interval for the sales order records. This helps to sort out and adapt the data set for the analytics use case. By definition in the ‘Sales Fact’ view, the sales orders covers the years from 2020 to 2023 (Jan-May).
Select the Add Variable ‘+’ button in the Variables section.
Choose Filter Variable.

Dimension: Year (OrderCreationDate)
Filter Type: Interval
From: 2021
To: 2023

Select the Sales Analytic Model link to return to the main panel overview.
Select the Fact Sources (1) node on the canvas.
In the analytic model properties overview in the side panel, the measures, dimensions, and variables are displayed. These properties are exposed for consumption in SAP Analytics Cloud. The dimensions belonging to the first, second and third level on the canvas are in the properties overview arranged on the same level, aligning to SAP Analytics Cloud standard.

Let’s save and deploy the analytic model before previewing it from an analytics perspective.
Select the Deploy icon in the header menu.

Confirm the name Sales Analytic Model, if asked.
Wait until the notification window appears that the deployment was successful.
Congratulations! You have successfully explored the modeling perspective of the Analytic Model tool, specified the measures and dimensions for the model, and created business measures, input variables, and filter variables. The draft model can be previewed to prepare it for analytic consumption in SAP Analytics Cloud (SAC).