Cube function

CUBERANKEDMEMBER function

Returns the nth member of a set, such as the top rep or the second-best product, from a Data Model or cube.

Available in Excel 2007 and later for Windows, Microsoft 365, Excel for the web (with Data Model or supported OLAP sources); Excel for Mac 2016+ for the Data Model

Excel 2007 and laterNot in Google Sheets

Syntax

CUBERANKEDMEMBER(connection, set_expression, rank, [caption])
ArgumentWhat it means
connectionRequiredThe cube connection name, e.g. "ThisWorkbookDataModel".
set_expressionRequiredA set: usually a reference to a cell with a CUBESET formula, or an MDX set expression.
rankRequiredWhich member to return: 1 for the first in the set's order, 2 for the second, and so on.
captionOptionalText to display instead of the member's own caption.

Returns: A member object; the cell shows the member's caption (e.g. Ana).

How CUBERANKEDMEMBER works

CUBERANKEDMEMBER pulls one item out of a sorted set by its position. Combined with a CUBESET that is sorted by a measure, it gives you a top-N list straight from the Data Model: rank 1 is the best rep, rank 2 the next, and so on. Next to it, a CUBEVALUE fetches each member's figure.

The examples use the sample Sales table (Rep, Region, Product, Units, Revenue) loaded into the workbook's Data Model - for example by ticking Add this data to the Data Model when inserting a PivotTable, or by loading it from Power Query. The Data Model's connection is always called ThisWorkbookDataModel, and a measure named Total Revenue (=SUM(Sales[Revenue])) was added with Power Pivot or the Add Measure command. Cell A1 holds =CUBESET("ThisWorkbookDataModel", "[Sales].[Rep].[All].Children", "Reps by revenue", 2, "[Measures].[Total Revenue]"), which sorts the reps by revenue, highest first.

Because the member is returned to the cell, it can be used just like a CUBEMEMBER - as a row header for CUBEVALUE formulas. When the data changes and the ranking shifts, the names and values update on refresh.

Examples

1Best rep

B3fx=CUBERANKEDMEMBER("ThisWorkbookDataModel", $A$1, A3)
ABC
1Reps by revenue
2RankRepRevenue
31Ana
42

Result: Ana

A3 holds 1, so the first member of the sorted set is returned: Ana, with 3600 + 1800 = 5400 in revenue. Copied to B4, rank 2 returns Dev.

2Value for the ranked rep

C3fx=CUBEVALUE("ThisWorkbookDataModel", "[Measures].[Total Revenue]", B3)
ABC
1Reps by revenue
2RankRepRevenue
315400
42

Result: 5400

B3 holds the member returned by CUBERANKEDMEMBER, so CUBEVALUE returns Ana's total revenue.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 13 KB

Common errors and how to fix them

ErrorWhy it happensFix
#N/Arank is larger than the number of members in the set, or the set is invalid.Check the rank against CUBESETCOUNT.
#VALUE!rank is 0, negative or not a number.Use 1 or more.
#GETTING_DATAThe set or member is still loading.Wait a moment.

Tips

  • Put rank numbers 1-10 in a column and copy the formula down for a top-10 report.
  • If the set is not sorted (sort_order 0), ranks follow the cube's natural order, not the values.

Google Sheets

No OLAP cube functions; use SORTN or QUERY with ORDER BY and LIMIT for top-n lists.

CUBERANKEDMEMBER in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
DanishKUBERANGERET.MEDLEM
DutchKUBUSGERANGSCHIKTLID
FinnishKUUTIONLUOKITELTUJÄSEN
FrenchRANGMEMBRECUBE
GermanCUBERANGELEMENT
HungarianKOCKA.HALM.ELEM
ItalianMEMBRO.CUBO.CON.RANGO
Norwegian (Bokmål)KUBERANGERTMEDLEM
PolishUSZEREGOWANY.ELEMENT.MODUŁU
Portuguese (Brazil)MEMBROCLASSIFICADOCUBO
Portuguese (Portugal)MEMBROCLASSIFICADOCUBO
RussianКУБПОРЭЛЕМЕНТ
SpanishMIEMBRORANGOCUBO
SwedishKUBRANGORDNADMEDLEM
TurkishDERECELİKÜPÜYESİ