Skip to Content
Technical Articles
Author's profile photo Bradley Vasilik

Creating Compound Keys in Datasphere

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%20Dataset

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!

Assigned Tags

      5 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Andreas Dietz
      Andreas Dietz

      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

      Author's profile photo Munjarin Bagwan
      Munjarin Bagwan

      from where did you take the dataset for anlytical modelĀ  CO-object line

      Author's profile photo Bradley Vasilik
      Bradley Vasilik
      Blog Post Author

      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.

       

      Author's profile photo Munjarin Bagwan
      Munjarin Bagwan

      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.

      Author's profile photo Hanhai Zou
      Hanhai Zou
      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.