Time Dependency for Dimensions and Texts in Analytic Model
Wagner Sabino .’.
BI Specialist (SAP Analytics, Datasphere, BW, HanaDB, S/4 Embbeded Analytics, SAC, BO)
23-08-2024
Introduction
The?SAP Datasphere Analytic Model Series is intended to provide you with useful guidance on how to utilize the new Analytic Model to leverage the potential of your data landscape. The Analytic Model allows for rich analytical modelling in a targeted modelling environment and will be THE go-to analytic consumption entity for SAP Datasphere. This article is the 7th of the blog post series and introduces Time Dependency for Dimensions and Texts in Analytic Model.
Business Value
Master data often changes over time. This is known as “time-dependency”. Let us take “Employee” as an example, an employee could change the marital status, the record in the system will be like this:
With this feature enabled, the report could display appropriate marital status for any given time period.
How to Apply
Modelers can specify the periods of validity of each record of your dimension or text entity. The following illustrations are based on below simple data model:
Dimension: Employee_TimDep, is associated with Analytical Dataset: V_Sales_TD, which is the fact source of Analytic Model AM_TimeDep. Three steps are required to implement the time-dependency feature in Analytic Model.
Step 1: Specify Time-Dependent Semantic Types in your Dimension or Text Entity In above example of dimension: Employee_TimDep, make the changes accordingly as below:
By default, the “Business Date - From” and “Business Date - To” are treated inclusively, however you could change the behavior, please refer to SAP Help: Enable Time-Dependency for a Dimension or Text Entity. Step 2: Associate the dimension with Analytical Dataset and create Analytic Model Any Analytical Dataset pointing to a time-dependent dimension via an association automatically benefits from its time-dependent data. The dimension members and their names are displayed based on the current date by default. Technically, this means that reference date is pushed down in the WHERE condition when the dimension members or text members are selected during query execution. For example, let’s create an association on the Analytical Dataset: V_Sales_TD.
领英推荐
As the reference date (aka key date) is not specified, the system uses the current date by default. Click on the button “Create Analytic Model” on the panel of Analytical Dataset: V_Sales_TD.
After deployment of Analytic Model: AM_TimeDep, perform the data preview to verify the data. The current date is April 24th in 2023, the retrieved “Marital_Status” is “Married”.
Step 3 (Optional): Add a variable to allow SAP Analytics Cloud users to enter a date of their choice and show dimension members based on that key date With Analytic Model, there is a new variable type called “Reference Date Variable”, which provides the flexibility of choosing a key date on your own choice.
Note that a model can only have one reference date variable. Data preview of Analytic Model will show the prompt to set the reference date variable:
The test data of Employee is as below:
Enter “2020-04-15” as key date, the marital status shows “Single”. Enter “2020-04-16”, it shows “Married”.
So far reference date variable on Analytic Model does not support scripting on default value (e.g., set to current date), SAP Analytics Cloud does offer scripting of prompts though that we can leverage to our benefit. With the New Optimized Story Experience in SAP Analytics Cloud that unifies the story and analytic application, you could write scripting in story, e.g., on event “onInitialization” during page initial loading, set prompt of key date to current date or a calculated date (like beginning of this week).
Conclusion
This blog provided an introduction and detailed steps to implement time dependency of dimensions and texts with the new Analytic Model in SAP Datasphere. The new reference date variable in Analytic Model makes this task even more practical for modelers. Thanks for reading! I hope this post was useful to you. Remember, continually deepening your knowledge of analytical tools is essential to stay up to date and optimize your skills. For questions or feedback, leave a comment below.
If you want to follow more content like this and continue to improve your knowledge, be sure to follow me on LinkedIn!