Retrieving Property Values from Dimensions using Tables in Analytic Applications
2023-11-8 14:46:25 Author: blogs.sap.com(查看原文) 阅读量:39 收藏

In this blog post, I will provide you with a comprehensive and step-by-step explanation of how to retrieve property values from any dimension within SAP Analytics Cloud (SAC). I will walk you through the intricacies of the process, ensuring a thorough understanding of the methods and techniques involved.

There was already an easier way to retrieve properties using the Planning Model’s getMembers() method. However, with the 2023 Q4 update, they may restricted access to master data for non-generic dimensions. As a result, we had to find an alternative method to obtain properties from dimensions, which led us to using tables in stories or analytical applications. Let’s get started.

Prerequisites

  • An active SAP Analytics Cloud account
  • Access to a story or analytical application where you can create tables and buttons

Steps to Retrieve Property Values

  1. Create a table in your story or analytical app:
  • Open your story or create a new one in SAP Analytics Cloud.
  • Add a table to the canvas.
  • In the table, include all dimensions for which you need property values. For this example, let’s consider the ‘Version’ dimension.

Table Example

2. Show the property of the dimension:

  • Right-click on the ‘Version’ dimension in the table.
  • From the context menu, select ‘Show/Hide’ and then choose your desired property from the ‘Properties’ option.

Property Selection Example

3. Create a button and add the following JavaScript code:

Button Creation

Insert the following code in the onClick function:

/*
var selection = {
    "DIMENSION_NAME": "PROPERTY_ID"
};
*/

var selection = {
    "Version": "public.Actual"
};

var resultSet = Table_1.getDataSource().getResultSet(selection, 0, 1);

// Log the entire result set to the console
console.log(resultSet);

// Access the specific property value (e.g., START_DATE) from the result set
/* var startDate = resultSet[0]["DIMENSION_NAME"].properties["DIMENSION_NAME.PROPERTY_ID"]; */
var startDate = resultSet[0]["Version"].properties["Version.START_DATE"];

// Log the property value to the console
console.log(startDate);
// Output: 202312

Console%20Output

Console Output

Explanation of the Code

The provided JavaScript code demonstrates how to obtain property values from the ‘Version’ dimension in SAC. First, we create a selection object specifying the desired dimension value. We then use the getResultSet() method to retrieve the data, limiting the result to one entry. Finally, we access the specific property value, in this case, ‘START_DATE’, from the result set and log it to the console.

Conclusion

By following these steps and utilizing the provided code, you can efficiently retrieve property values from any dimension in SAP Analytics Cloud. This method provides a reliable solution even after the 2024 Q4 update restrictions.


文章来源: https://blogs.sap.com/2023/11/08/retrieving-property-values-from-dimensions-using-tables-in-analytic-applications/
如有侵权请联系:admin#unsafe.sh