sisense.com
✅ You are viewing documentation for the latest version of Compose SDK.
Version:

Function measureTopRanking

measureTopRanking( measure, count, config?): Filter

Creates a filter that returns the top N values of the last dimension, independently for each unique combination of all preceding dimensions.

This filter applies ranking within groups rather than globally. It shows the top N values of the rightmost dimension for every unique combination of the other dimensions to its left. The order of dimensions in your query determines the grouping behavior.

Key Differences from topRanking:

  • topRanking: Filters a specific dimension globally (you specify which dimension)
  • measureTopRanking: Always filters the last/rightmost dimension, grouped by all others

How it works:

  • With 1 dimension: Returns the top N values of that dimension
  • With 2+ dimensions: Returns the top N values of the LAST dimension for each combination of the others

Parameters

ParameterTypeDescription
measureBaseMeasureBase measure to rank by
countnumberNumber of items to return per group (applies to the last dimension)
config?BaseFilterConfigOptional configuration for the filter

Returns

Filter

A filter instance

Example

Example 1: Single dimension (equivalent to topRanking) - Query with one dimension [Category]

// Returns top 5 Categories by total revenue
filterFactory.measureTopRanking(
  measureFactory.sum(DM.Commerce.Revenue),
  5
)

Result: 5 categories (e.g., Cell Phones, Computers, TVs, etc.)

This produces the same result as:

filterFactory.topRanking(
  DM.Commerce.Category,
  measureFactory.sum(DM.Commerce.Revenue),
  5
)

Note: With only one dimension, there are no groups to rank within, so the behavior is identical to topRanking.

Example

Example 2: Two dimensions - Query with dimensions [Gender, Category]

// Returns top 2 Categories for each Gender
filterFactory.measureTopRanking(
  measureFactory.sum(DM.Commerce.Revenue),
  2
)

Result: 3 genders × 2 categories each = 6 rows

  • Male: Top 2 categories by revenue
  • Female: Top 2 categories by revenue
  • Unspecified: Top 2 categories by revenue

Example

Example 3: Three dimensions - Query with dimensions [Gender, Age Range, Category]

// Returns top 2 Categories for each (Gender, Age Range) combination
filterFactory.measureTopRanking(
  measureFactory.sum(DM.Commerce.Revenue),
  2
)

Result: 3 genders × 7 age ranges × 2 categories per combination = ~42 rows

Last Updated: