Using OLAPGetElementsAttributeValues and OLAPGetElementsAttributesValues functions

The purpose of the OLAPGetElementsAttributeValues and OLAPGetElementsAttributesValues functions is to read a single attribute or multiple attribute values for a set of elements from OLAP.

These functions enable a huge performance improvement, because the need of a separate OLAP request for each attribute value has become obsolete.

The subsequent code example shows how to use these functions:

#define EngineVersion 5.0 
#define RuntimeVersion 5.0 
void TestOLAPGetElementsAttributesValues() 
@Description: " Read Attribute Values "; 
@Returns: "void"; 
@Category: "Show"; 
{ 
  string sDimension = "REGION"; string sHierarchy = "REGION"; 
  // Connect to Olap. 
  OLAPConnection olapConnection = CreateTestConnection();
  // We use all elements of this dimension. 
  OLAPDimension dimension = OLAPGetDimension(olapConnection, sDimension);
  // Here we obtain the list of the elements
  OLAPElementList elementList = OLAPGetElementList(olapConnection, dimension, true); 
  // we will read three attributes for each of the elements 
  StringList attrList = CreateStringList(); 
  Append(attrList, "English"); 
  Append(attrList, "Spanish"); 
  Append(attrList, "French");

  // Here we call the function that reads all the attribute values with a single request to OLAP 
  StringListList sll = OLAPGetElementsAttributesValues(olapConnection, sDimension, sHierarchy, elementList, attrList);
  // here we print you each of the elements and the three requested attribute values 
  int i = 0; 
  foreach (StringList sl in sll) 
  { 
    string row = elementList[i] + ": "; 
    foreach (string attr in sl) { row = row + " " + attr; } 
    WriteLine(row); i = i + 1; 
  } 
  // disconnect from Olap. 
  OLAPDisconnect(olapConnection); 
}

Both functions throw an exception with a corresponding message in case of requesting a non-existing attribute or in case of receiving an error from OLAP.