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])| Argument | What it means | |
|---|---|---|
connection | Required | The cube connection name, e.g. "ThisWorkbookDataModel". |
set_expression | Required | A set: usually a reference to a cell with a CUBESET formula, or an MDX set expression. |
rank | Required | Which member to return: 1 for the first in the set's order, 2 for the second, and so on. |
caption | Optional | Text 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
| A | B | C | |
|---|---|---|---|
| 1 | Reps by revenue | ||
| 2 | Rank | Rep | Revenue |
| 3 | 1 | Ana | |
| 4 | 2 |
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
| A | B | C | |
|---|---|---|---|
| 1 | Reps by revenue | ||
| 2 | Rank | Rep | Revenue |
| 3 | 1 | 5400 | |
| 4 | 2 |
Result: 5400
B3 holds the member returned by CUBERANKEDMEMBER, so CUBEVALUE returns Ana's total revenue.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#N/A | rank 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_DATA | The 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.
| Language | Function name |
|---|---|
| Danish | KUBERANGERET.MEDLEM |
| Dutch | KUBUSGERANGSCHIKTLID |
| Finnish | KUUTIONLUOKITELTUJÄSEN |
| French | RANGMEMBRECUBE |
| German | CUBERANGELEMENT |
| Hungarian | KOCKA.HALM.ELEM |
| Italian | MEMBRO.CUBO.CON.RANGO |
| Norwegian (Bokmål) | KUBERANGERTMEDLEM |
| Polish | USZEREGOWANY.ELEMENT.MODUŁU |
| Portuguese (Brazil) | MEMBROCLASSIFICADOCUBO |
| Portuguese (Portugal) | MEMBROCLASSIFICADOCUBO |
| Russian | КУБПОРЭЛЕМЕНТ |
| Spanish | MIEMBRORANGOCUBO |
| Swedish | KUBRANGORDNADMEDLEM |
| Turkish | DERECELİKÜPÜYESİ |