Changing the weight of a parent-child relationship between elements

The purpose of the OLAPChangeElementWeight function is to change the weight of a parent-child relationship between elements.

This is the declaration of the OLAPChangeElementWeight function:

void OLAPChangeElementWeight (OlapConnection connection, string dimension, string element, string parentElement, double weight)

These are the parameters of the OLAPChangeElementWeight function:

Parameters Description
connection An OLAP connection to get the data from.
dimension The name of the dimension that must contain the element and the parent element.
element The name of the element whose weight is to be changed.
parentElement The name of the parent element from the parent-child relationship.
weight The new value of the weight to be set on the parent-child relationship.

The OLAPChangeElementWeight function does not return a value.

The OLAPChangeElementWeight function throws an exception in these cases:

  • The dimension does not exist.
  • An element does not exist.

The subsequent code example shows how to use this function:

#define EngineVersion 5.0
#define RuntimeVersion 5.0

void MyOLAPChangeElementWeight (string element, string parentElement, double weight)
@Description: "Demonstrates how to change the element weight";
@Category: "Demo";
@Parameter[element]: "Specify element";
@Parameter[parentElement]: "Specify parent element";
@Parameter[weight]: "Specify weight";
{
	string dimension = "Product";

	// 1. Create a connection to the OLAP server.
	OLAPConnection olapconnection=OLAPCreateNamedConnection("");

	// 2. Change the weight
	OLAPChangeElementWeight(olapconnection, dimension, element, parentElement, weight);

	// 3. Close OLAP connection
	OLAPDisconnect(olapconnection);
}