Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
vasilikb
Advisor
Advisor

Business value


When defining tables in Datasphere, sometimes, one key will not be refined enough to define the uniqueness of records.

The sample data below shows 2 columns that are keys

  • Controlling area

  • Cost Center



Sample Dataset



How to apply compound keys


Modelers will first need to create an entity of one of the below semantic usages selected:

  • Dimension

  • Text

  • External Hierarchy


This can be defined at the local table level or a view level.

In addition, another view of transactional data will be required to complete the model.

This example highlights creation of a compound key for the below flow from the dimension to the Analytic Model preview.


To implement the compound key, 4 steps are required.

  • Step 1: Create a dimension and ensure it has key values

  • Step 2: Define key order and representative key

  • Step 3: Create a model and associate the dimension to the model

  • Step 4: Build analytic model for consumption


Step 1: Ensure the dimension has key values


In the local table, define the primary keys (this can also be done at a view level)



Step 2: Define key order and representative key


The compound key will be defined at this step. It is important to take two considerations while completing these steps

  • Define a representative key that holds the most granular level of data

  • Order the key columns in the appropriate manner if there is more than 2 keys




Step 3: Create a model and associate the dimension to the model


Define an analytical dataset and create an association to the CostCenters dimension.



Step 4: Build analytic model for consumption


We can now create an analytic model by dragging in the analytical dataset with the associated dimension and view the result of the compound key in the result set.



Summary


Now should be able to view compound keys in our Analytic Models, SAC stories and SAC Add-in for Microsoft Office.

Please like, comment or post a question!
6 Comments
AndreasDietz
Explorer
Splendid! It solves the issue with error messages in analytic models 'representative key missing ...'. Thanks to my collegue who knew the blog we were able to solve the issue.

 

Thanks

Andreas
munjarin
Discoverer
0 Kudos
from where did you take the dataset for anlytical model  CO-object line
vasilikb
Advisor
Advisor
0 Kudos
I took a simple ABAP table from one of my test systems with dummy data. It is pulled from the ABAP COEP table of an S/4HANA system. This was purely for demo purposes.

 
munjarin
Discoverer
Can we hide a compound key while presenting in preview for example, here in blog  example in the preview we can see Cost Center\Controlling Area can we just show it by Cost Center or Controlling Area.
hanhai
Newcomer
0 Kudos
Hi, if we use this to create a level hierarchy, is it possible that we can also show the text for the higher level and not only for the lowest level?


For example, I think that in your case you can only show the description for the cost center but not the controlling area, right? Even if we associate the text table to the controlling area in the dimension, it is not possible to display it in the hierarchy.
datasfear
Discoverer
0 Kudos

Hi, thanks a lot for your work!

We have implemented it as in your description and added an association "text view" for cost center texts to the dimension view of cost center. 

When we open the report (or the analytic model preview) the cost center texts are displayed. But they are not displayed, when we use the cost center as a variable in the prompt. Unfortunately SAP couldn't help us with this issue.

Do you have any idea how to get texts displayed in the prompt when the charactistic is compounded (like cost center and controlling area).

 

Thank you in advance!

 

Kind regards

Stefan