Pivot selectors

Selectors are objects that select elements in a pivot for different purposes, such as applying style rules and configuring the pivot axes. Pivots are stored as hierarchical tree structures, and selectors take care of selecting the correct row, column, and measure when needed.

In the next section, we will create a report style for the pivot. This report style changes the formatting of cells in the pivot, similar to the conditional formatting rules we created for the table view. A report style must be supported by a measure value selector, which selects the cells to apply the style to based on a measure. We create this selector using workbook.createMeasureValueSelector(options). This method accepts a row selector, column selector, and measure selector. The row selector and column selectors are workbook.DescendantorSelfNodesSelector objects, which are generic selectors that work in many situations. The measure selector must be created based on the measure to select (our calculated measure above) using workbook.createMeasureValueSelector(options).

We also create another workbook.DescendantorSelfNodesSelector, which we will use when we create the pivot axes in a later section.

          var conditionalRowSelector = nWorkbook.DescendantOrSelfNodesSelector;
var conditionalColumnSelector = nWorkbook.DescendantOrSelfNodesSelector;
var conditionalMeasureSelector = nWorkbook.createMeasureSelector({
    measures: [calculatedMeasure]
});

var measureValueSelector = nWorkbook.createMeasureValueSelector({
    rowSelector: conditionalRowSelector,
    columnSelector: conditionalColumnSelector,
    measureSelector: conditionalMeasureSelector
});

var allSubNodesSelector = nWorkbook.DescendantOrSelfNodesSelector; 

        

Related Topics

General Notices