OLAPLabels (Collection)

Member of:

OLAPQuerySection object

Description:

Consists of the OLAP Query TopLabels and SideLabels collections. These collections correspond to the labels within a OLAP Query section. These are columns added to the side and top labels groups in the outliner.

Interactive Reporting supports different OLAP datasource, including OLEDB for DB, Essbase, and MetaCube. Depending on the data source, different filter operators are supported. If you use an operator that is not applicable for the data source, an exception is thrown.

OLEDB for OLAP only enables users to add filter values by selecting them from the Show Values pane in the Filter dialog box. Essbaseand MetaCube enable users to type in a string as the default way of adding filter values and provides a Filter dialog. When not using Show Values, use the optional parameter value in the Add () method for filtering.

Tip:

All collections have the “Item(NameOrIndex)” method. This is the default method for all collections that returns collection items at a particular index or by name. Use brackets ([]) to represent calls to the Item (Method). For example, these statements are identical: myItem = Documents[1] myItem = Documents.Item(1) myItem = Documents["StartUp.bqy"] myItem = Documents.Item("StartUp.bqy")

Constants:

The OLAPLabels (Collection) uses the BqOperator constant group, which consists of these values:·

Examples:

The following scripts show an OLAPQuery with these values:

The scripts invoke the Console window to monitor each line that is executed.

Observe the hierarchy of dimensions and labels when you create scripts that include OLAP objects, methods, and properties. Levels from the same dimension must be grouped together in both side and top labels. Additionally, do not break dimensional hierarchy. For example, Year must proceed Quarter, which proceeds Month.

Example 1:

This script shows how to remove all labels. If label don't exist, use a try-catch statement:

OQPath = ActiveDocument.Sections["OLAPQuery"]
/*try-catch used here in case labels don't exist*/
Console.Writeln("Step1")
try{OQPath.SideLabels[1].Remove()}
catch(e)
{Console.Writeln(e.toString())}
Console.Writeln("Step2")
OQPath.Process()
Console.Writeln("End")

Example 2:

This script shows how to add the "State" value as the side label. Note the hierarchy in which the dimension "Location" proceeds the level "State".

Console.Writeln("Start")
OQPath = ActiveDocument.Sections["OLAPQuery"]
Console.Writeln("Step1")
OQPath.SideLabels.Add('Location.State')
Console.Writeln("Step2")
OQPath.Process()
Console.Writeln("End")

Example 3:

This script adds the Arizona state abbreviation code as a filter value. The State side label must already exist.

Console.Writeln("Start")
OQPath = ActiveDocument.Sections["OLAPQuery"]
Console.Writeln("Step1")
OQPath.SideLabels[1].AddFilterValue('AZ',bqOperatorEqual)
Console.Writeln("Step2")
OQPath.Process()
Console.Writeln("Step3")
OQPath.Activate()
Console.Writeln("End")

Example 4:

In this example, the state added in Example 3 is removed and a filter can be added from the drop-down list:

Console.Writeln("Start")
OQPath = ActiveDocument.Sections["OLAPQuery"]
Console.Writeln("Step1")
//try-catch used here in case labels don't exist*/try{OQPath.SideLabels[1].Remove()}
catch(e){}
Console.Writeln("Step2")
OQPath.SideLabels.Add('Location.State')
Console.Writeln("Step3")fv = DropDown1[DropDown1.SelectedIndex]
Console.Writeln("Step4, fv is " + fv)
OQPath.SideLabels[1].AddFilterValue(fv,bqOperatorEqual)
Console.Writeln("Step5")
OQPath.Process()
Console.Writeln("Step6")
OQPath.Activate()
Console.Writeln("End")

Example 5:

When you do not want to use the ShowValues property of filtering, use the Add () method as shown below.

//When NOT using Show Value method of filteringActiveDocument.Sections["OLAPQuery"].
TopLabels.Add(‘Time.Year’,’1999’)

Example 6:

When you want to use the ShowValues property of filtering, use the AddFilterValue method.

ActiveDocument.Sections["OLAPQuery"].TopLabels.Add('Gender.Gender')
ActiveDocument.Sections["OLAPQuery"].TopLabels["Gender"].AddFilterValue('M',bqOperatorEqual)

Methods:

Add(String LevelName), Function Item(Value As NameOrIndex) As OLAPLabel, RemoveAll()

Properties:

Read-only: Property Count As Number

TopLabels Methods and Properties:

ActiveDocument.Sections["OLAPQuery"].TopLabels.Add(‘LevelName’[,optionalMeasure])
ActiveDocument.Sections["OLAPQuery"].TopLabels.Item()
ActiveDocument.Sections["OLAPQuery"].TopLabels.RemoveAll()
ActiveDocument.Sections["OLAPQuery"].TopLabels.Count
ActiveDocument.Sections["OLAPQuery"].TopLabels[‘LevelName’].Remove()
ActiveDocument.Sections["OLAPQuery"].TopLabels[‘LevelName’].FilterOperator= bqOperator
ActiveDocument.Sections["OLAPQuery"].TopLabels[‘LevelName’].AddFilterValue(‘LevelName’,’MeasureName’)

SideLabels Methods and Properties:

ActiveDocument.Sections["OLAPQuery"].SideLabels.Add(‘LevelName’[,optionalMeasure])
ActiveDocument.Sections["OLAPQuery"].SideLabels.Item()ActiveDocument.Sections["OLAPQuery"].SideLabels.RemoveAll()
ActiveDocument.Sections["OLAPQuery"].SideLabels.Count
ActiveDocument.Sections["OLAPQuery"].SideLabels[‘LevelName’].Remove()
ActiveDocument.Sections["OLAPQuery"].SideLabels[‘LevelName’].FilterOperator= bqOperator
ActiveDocument.Sections["OLAPQuery"].SideLabels[‘LevelName’].AddFilterValue(‘LevelName’,’MeasureName’)