bindingInfo.setTopN(field, header, number)

Sets the number of row or column groups to preserve in the ranking. This is equivalent to setting the number ‘N’ of ranking groups for the ‘Rank’ property of the Crosstab Editor.

crosstab editor showing Rank N option for filtering top groups

Parameters

field

String: Name of a column to rank

header

StyleConstant.ROW_HEADER or StyleConstant.COLUMN_HEADER

number

Integer: Number of groups to select

Example

Crosstab1.query = 'Sales';
Crosstab1.bindingInfo.rowFields = ['Name'];
Crosstab1.bindingInfo.colFields = ['Region'];
Crosstab1.bindingInfo.measureFields = ['Total'];
Crosstab1.bindingInfo.setFormula('Total', StyleConstant.SUM_FORMULA);
Crosstab1.bindingInfo.showColumnTotal = true;
Crosstab1.bindingInfo.setTopN('Name',StyleConstant.ROW_HEADER,3);
Crosstab1.bindingInfo.setTopNSummaryCol('Name',StyleConstant.ROW_HEADER,'Sum(Total)');
Crosstab1.bindingInfo.setTopNReverse('Name',StyleConstant.ROW_HEADER,false);

crosstab showing top 3 names by Sum of Total with column totals

Either syntax below can be used in component script:

bindingInfo.setTopN             // unqualified
Crosstab1.bindingInfo.setTopN   // qualified

For onInit/onRefresh scripts, and for component and property scripts on other components, the second (qualified) form is required.