CUBESETCOUNT function
Counts the number of items in a set created by CUBESET.
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
CUBESETCOUNT(set)| Argument | What it means | |
|---|---|---|
set | Required | A reference to a cell containing a CUBESET formula, or a CUBESET expression. |
Returns: A whole number: how many members the set contains.
How CUBESETCOUNT works
CUBESETCOUNT tells you how many members are in a set - how many reps, products or customers a CUBESET returned. It is mostly used to make top-N or full-list reports adapt to the data: you can check whether a rank exists before asking CUBERANKEDMEMBER for it, or show a heading such as "4 reps".
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. In the examples, A1 holds =CUBESET("ThisWorkbookDataModel", "[Sales].[Rep].[All].Children", "Reps by revenue", 2, "[Measures].[Total Revenue]") and A2 holds the products set.
Examples
1How many reps?
| A | B | |
|---|---|---|
| 1 | Reps by revenue | 4 |
| 2 | Products |
Result: 4
The rep set in A1 contains Ana, Ben, Chloe and Dev.
2How many products?
| A | B | |
|---|---|---|
| 1 | Reps by revenue | |
| 2 | Products | 3 |
Result: 3
The product set in A2 has Laptop, Monitor and Mouse.
3Hide ranks that do not exist
| A | B | |
|---|---|---|
| 1 | Reps by revenue | |
| 2 | Products | |
| 3 | Chloe |
Result: Chloe
The set has four reps, so rank 4 exists and the lowest earner, Chloe, is shown. In a row asking for rank 5 the same check returns empty text instead of an error.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#VALUE! | The reference does not point to a CUBESET cell. | Reference the cell with the CUBESET formula. |
#GETTING_DATA | The set is still loading. | Wait a moment. |
Tips
- The cell with the set itself shows only its caption - CUBESETCOUNT is the easiest way to check the set has loaded the members you expect.
Google Sheets
No OLAP cube functions; count rows of a QUERY or FILTER result with ROWS instead.
CUBESETCOUNT 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 | KUBESÆT.ANTAL |
| Dutch | KUBUSSETAANTAL |
| Finnish | KUUTIOJOUKKOJENMÄÄRÄ |
| French | NBJEUCUBE |
| German | CUBEMENGENANZAHL |
| Hungarian | KOCKA.HALM.DB |
| Italian | CONTA.SET.CUBO |
| Norwegian (Bokmål) | KUBESETTANTALL |
| Polish | LICZNIK.MODUŁÓW.ZESTAWU |
| Portuguese (Brazil) | CONTAGEMCONJUNTOCUBO |
| Portuguese (Portugal) | CONTARCONJUNTOCUBO |
| Russian | КУБЧИСЛОЭЛМНОЖ |
| Spanish | RECUENTOCONJUNTOCUBO |
| Swedish | KUBUPPSÄTTNINGANTAL |
| Turkish | KÜPKÜMESAYISI |