Use Selection API for Tables and Charts

You can use the selection API in SAP Analytics Cloud, analytics designer for tables and charts to retrieve the currently selected members and their dimensions.

Get a Selection

The getSelections() API returns an array of Selection objects, each representing a single selection.

Selection API Functions
Selection API Function Return Value
Table_1.getSelections() array of Selection (= Object<string>)
Chart_1.getSelections() array of Selection (= Object<string>)

The properties of such a Selection object are the dimension IDs. The values are the member IDs.

Sample Code
{ 

   "dim1": "member1",  

   "dim2": "member2"

}

You can access the selected member of a dimension using var memberId = selection[“dimensionId”];

You can iterate over all dimensions of a selection with a for-in loop like this:
Sample Code
var selection = Table_1.getSelections()[0];

for (var dimensionId in selection) {

   var memberId = selection[dimensionId];

}

Use a Selection

With a selection you can retrieve specific data from data sources.

DataSource.getData() expects a selection object:
Sample Code
var selection = Table_1.getSelections()[0];

var dataCell = Table_1.getDataSource().getData(selection);

When you specify the selection object to be passed onto a getData() call, a value help for dimensions and members helps you enter the required dimension and member IDs.