Cube function

CUBEVALUE function

Returns an aggregated value, such as total revenue for a region, from a Data Model or OLAP 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

CUBEVALUE(connection, [member_expression1], [member_expression2], ...)
ArgumentWhat it means
connectionRequiredThe cube connection name, e.g. "ThisWorkbookDataModel".
member_expression1, ...OptionalMembers or sets that slice the cube: usually a measure plus one or more items, given as MDX text or as references to cells containing CUBEMEMBER or CUBESET. If no measure is given, the cube's default measure is used.

Returns: The number at the intersection of all the given members - e.g. the Total Revenue for North.

How CUBEVALUE works

CUBEVALUE is where the numbers come from in a cube-formula report. You pass it a connection and a list of members - a measure such as Total Revenue and items like North or Laptop - and it returns the value at their intersection, calculated by the Data Model or the OLAP server. Think of it as SUMIFS for a Data Model: each member is a condition.

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.

The typical layout puts CUBEMEMBER formulas in the row and column headers and one CUBEVALUE in the body that refers to them with mixed references, so it can be copied across the whole grid. Unlike a PivotTable, the layout is completely free: you can insert blank rows, add your own formulas next to the values, and mix values from different sources. If a combination has no data, CUBEVALUE returns an empty value that displays as a blank cell.

Examples

1Revenue for the region in a header cell

B2fx=CUBEVALUE("ThisWorkbookDataModel", "[Measures].[Total Revenue]", $A2)
AB
1RegionRevenue
2North4638
3South
4East

Result: 4638

A2 contains a CUBEMEMBER formula for North. CUBEVALUE combines it with the Total Revenue measure and returns North's revenue. Copied down, B3 and B4 return 5990 for South and 2160 for East.

2Two conditions typed as text

B6fx=CUBEVALUE("ThisWorkbookDataModel", "[Measures].[Total Revenue]", "[Sales].[Region].[All].[South]", "[Sales].[Product].[All].[Laptop]")
AB
1
2
3
4
5
64500

Result: 4500

Each member narrows the result: South and Laptop. Only Dev's laptop sale matches.

3Grand total

B7fx=CUBEVALUE("ThisWorkbookDataModel", "[Measures].[Total Revenue]")
AB
1
2
3
4
5
6
712788

Result: 12788

With only the measure, the value is not sliced by any region or product, so the whole table is summed.

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

Common errors and how to fix them

ErrorWhy it happensFix
#N/AA member name is invalid, or a referenced CUBEMEMBER cell shows an error.Fix the member expression; check the referenced header cells first.
#VALUE!One of the arguments refers to a cell that is not a cube member or set.Make sure every reference points to a CUBEMEMBER or CUBESET cell.
#NAME?The connection name is wrong or the OLAP server cannot be reached.Check the connection name in Data > Queries & Connections.
#GETTING_DATAThe value is still being retrieved.Wait a moment.

Tips

  • Use a mixed reference such as $A2 for row members and B$1 for column members so one formula fills the grid.
  • Slicers can be passed as arguments: a slicer's name (e.g. Slicer_Region) filters the value just like in a PivotTable.
  • Convert an existing PivotTable with OLAP Tools > Convert to Formulas to get working CUBEVALUE formulas instantly.

Google Sheets

No OLAP cube functions; use pivot tables, QUERY, or Connected Sheets for BigQuery data.

CUBEVALUE 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
DanishKUBEVÆRDI
DutchKUBUSWAARDE
FinnishKUUTIONARVO
FrenchVALEURCUBE
GermanCUBEWERT
HungarianKOCKA.ÉRTÉK
ItalianVALORE.CUBO
Norwegian (Bokmål)KUBEVERDI
PolishWARTOŚĆ.MODUŁU
Portuguese (Brazil)VALORCUBO
Portuguese (Portugal)VALORCUBO
RussianКУБЗНАЧЕНИЕ
SpanishVALORCUBO
SwedishKUBVÄRDE
TurkishKÜPDEĞERİ