Selecting Measures in OLAP Data

The SAS BIP graph component API supports selecting measures in OLAP data

For example, the following code fragment uses the [Measures].[ACTUAL_SUM] measure name to set a response variable role:


// Use a measure name to set the Response variable role
   olapDataModel.setResponseVariable(new AnalysisVariable("[Measures].[ACTUAL_SUM]"));

To use a result set ID, extract the ID from a business query. For example, you can build a business query using a BusinessQueryToOLAPDataSetAdapter, and then extract a result set from that query.

To extract the result set, you can call BusinessQueryToOLAPDataSetAdapter.getBusinessQuery() and use the returned BusinessQuery to load the result items into a List object. You can then loop through the List to get one or more result set IDs.

The following code fragment extracts the first measure from a BusinessQuery and uses that measure's result set ID to set a response variable role. If no measure is found, the Response role is set to null and the component finds a default measure in the OLAP data model:


String resultSetID = null;
BusinessQueryToOLAPDataSetAdapter bqtods = ...
List queryList = bqtods.getBusinessQuery().getResultItems();

// Return the first measure in the BusinessQuery list
   for (int i=0; i < queryList.size(); i++)
   {
       DataItem dataItem = (DataItem) queryList.get(i);
       if (dataItem.getUsage() != DataItemActionType.USAGE_CATEGORY)
       {
          resultSetID = dataItem.getResultSetID();
          break;
       }
   }

// Use the resultSetID to set the Response variable role
   olapDataModel.setResponseVariable(new AnalysisVariable(resultSetID));