The category table of ECMA-376 5th edition Part 1 (December 2016) section 18.17.7 lists seven cube functions (§18.17.7.65 to .71). They read from an OLAP cube on an OLAP server that a workbook connection names. This page gives each one’s syntax, arguments, return value and examples as the standard states them, then [MS-OI29500] v20260818’s notes, then what LibreOffice does. Section numbers are the standard’s own. The connections themselves are described on Data, links and revisions; OLAP pivot tables on Pivot tables.
What they share
The first argument of every cube function except CUBESETCOUNT is connection, text: the name of
a connection to the cube that is stored in the workbook. MDX (the standard calls it “a standard query
language for OLAP cubes”) is the language of the member, set and tuple expressions. When a cell that
holds a CUBEMEMBER or CUBESET result is used as an argument of another cube function, that function uses the
MDX expression of the cell, not the value the cell shows. The standard gives the same list of cases for
which “the return value is unspecified”: the connection is not a connection of the workbook, the
server is not running, unavailable or returns an error, and (where the function takes one) the expression is
malformed, names no existing member, is a tuple with no intersection, or is a set of members of different
dimensions. A cube function can therefore not be evaluated without the server; a file stores the value the
program saw when it last calculated.
The seven functions
| Function | Arguments | Returns (standard) | Examples |
|---|---|---|---|
CUBEKPIMEMBER (.65) | connection, kpi-name (text), kpi-property (number, truncated), optional caption (text, shown instead of name and property) | any: the Key Performance Indicator. #N/A if kpi-property is outside 1–6; unspecified if the KPI name does not exist | CUBEKPIMEMBER("Sales","MySalesKPI",1); CUBEKPIMEMBER("Sales","MySalesKPI",2,"Sales KPI Goal") |
CUBEMEMBER (.66) | connection, member-expression (text, reference or array: an MDX expression for a unique member, or a tuple as a cell range or array constant), optional caption | any: a member or tuple of the cube. Used to check that the member exists. For a tuple the caption is that of the last member | CUBEMEMBER("Sales","[Time].[Fiscal].[2004]"); CUBEMEMBER($A$1,D$12); CUBEMEMBER("Sales",(B4,C6,D5),"SalesFor2004"); CUBEMEMBER("Sales",{[Products].[Food];[Time].[Fiscal].[2004]}); CUBEMEMBER($A$1,C$12:D$12) |
CUBEMEMBERPROPERTY (.67) | connection, member-expression (text), property (text: the property name, or a reference to a cell holding it) | any: a property of a member | CUBEMEMBERPROPERTY("Sales","[Time].[Fiscal].[2004]",$A$3); CUBEMEMBERPROPERTY("Sales","[Store].[MyFavoriteStore]","[Store].[Store Name].[Store Sqft]") |
CUBERANKEDMEMBER (.68) | connection, set-expression (text, such as {[Item1].children}), rank (number, truncated: 1 is the top value, 2 the second, and so on), optional caption | any: the nth member of the set | CUBERANKEDMEMBER("Sales",$D$4,1,"Top Month"); CUBERANKEDMEMBER("Sales",CUBESET("Sales","Summer","[2004].[June]","[2004].[July]","[2004].[August]"),3,"Top Month") |
CUBESET (.69) | connection, set-expression (text or reference to a range of members, tuples or sets), optional caption, sort-order, sort-by (see below) | any: the set. sort-order outside 0–6 gives #N/A; an order that needs sort-by without it gives #VALUE! | CUBESET("Finance","Order([Product].[Product].[Product Category].Members,[Measures].[Unit Sales],ASC)","Products"); CUBESET("Sales","[Product].[All Products].Children","Products",1,"[Measures].[Sales Amount]") |
CUBESETCOUNT (.70) | set (text: an expression that evaluates to a set defined by CUBESET) | number: how many items the set has | CUBESETCOUNT(A3); CUBESETCOUNT(CUBESET("Sales","[Product].[All Products].Children","Products",1,"[Measures].[Sales Amount]")) |
CUBEVALUE (.71) | connection, an argument list of members, tuples or CUBESET sets (text or reference), used as slicers | any: the aggregated value. With no measure in an argument the cube’s default measure is used; a reference to a cell holding a cube function uses that cell’s MDX, not its displayed value | the standard prints the example line only in the page break; it shows no complete example |
kpi-property of CUBEKPIMEMBER
| Value | Component returned (standard) |
|---|---|
| 1 | The actual value at the time the function is executed. With 1, only kpi-name is displayed in the cell |
| 2 | A target value of the KPI, to compare with the actual value |
| 3 | The state of the KPI at a specific moment |
| 4 | A measure of the value over time |
| 5 | The relative importance assigned to the KPI on the server; the server may use it to adjust a parent KPI |
| 6 | The unique name of the member in the time dimension that defines the timeframe of the KPI (for example the first quarter of 2007) |
sort-order of CUBESET
| Value | Sort | sort-by |
|---|---|---|
| 0 or default | leaves the set in its existing order | ignored |
| 1 | ascending by sort-by | required |
| 2 | descending by sort-by | required |
| 3 | alphabetic ascending | ignored |
| 4 | alphabetic descending | ignored |
| 5 | natural ascending | ignored |
| 6 | natural descending | ignored |
An alphabetic sort of a set of tuples sorts on the last element of each tuple. The standard’s syntax
line for CUBEMEMBER, CUBEMEMBER ( connection , member-expression , [ , [ caption ] ] ), has a
stray comma before the optional caption; the examples call it with two or three arguments. The CUBERANKEDMEMBER
clause that lists the unspecified cases contains the fragment “, the return value is unspecified.”
twice, a copy slip.
Excel notes
- CUBEKPIMEMBER (MS-OI29500 2.1.914): (a) for
kpi-property5 Excel returns the relative importance of the KPI on the server, which the server can use to adjust a parent KPI (the standard does not say how it is used); (b) for 6 Office returns the unique name of the member of the time dimension that defines the KPI’s timeframe (the standard describes it as a temporal context). - CUBESET (2.1.915): where
sort-orderneedssort-bybut thesort-byvalue is not in the cube, Office returns #N/A (the standard does not define it). - CUBESETCOUNT (2.1.916): where
setdoes not evaluate to a set Office returns #N/A (the standard does not define it). - CUBEMEMBER (member-expression), CUBESET (set-expression) and CUBEVALUE (all arguments except
connection) are also named in the list of function arguments at MS-OI29500 line 17319 to 17321; the heading of that list was not read, so no meaning is given here.
LibreOffice
The examples of the standard that have no dependence on a server (the first seven rows of the oracle) were
written as formulas in a flat ODS made by samples/xlsx/oracle/make-fods.mjs from
formulas.txt and converted to CSV by soffice --headless --convert-to csv (files in
samples/xlsx/oracle/cubefn/). Every cube function returns #NAME?, also when the name is written with
the COM.MICROSOFT. prefix that LibreOffice needs for some Excel-only functions: LibreOffice has no
cube functions. A workbook that holds them shows the cached values of the file, and LibreOffice does not
recalculate them to anything else.
Web functions: not in Part 1
The category table of 18.17.7 lists eleven categories: cube, database, date and time, engineering, financial,
information, logical, lookup and reference, math and trigonometry, statistical, and text and data. There is no
web category, and a search of Part 1 for ENCODEURL, WEBSERVICE and
FILTERXML, the web functions of later Excel versions, finds none, and [MS-OI29500] names none
of them either. They are therefore not described here. LibreOffice does have two of them: with the
COM.MICROSOFT. prefix ENCODEURL("a b") returns a%20b and
FILTERXML("<a><b>1</b></a>","//b") returns 1 (the oracle rows 12 and 13).
What the viewer does
The viewer shows the value a cell stores and never recalculates a worksheet, so a cube function’s cached
value is shown as it is. The conditional-format calculator (explorer/formats/xlsx/cf.js) has none
of the cube functions: a rule that needs one is reported as not calculated and is not applied.
See also
- Data, links and revisions: connections, including OLAP
- Pivot tables: OLAP pivot caches and cube hierarchies
- Functions: lookup and reference: GETPIVOTDATA
- Formulas
Not described on this page
- Excel’s own results and the behaviour against a live server: only [MS-OI29500] was read; Excel was not run and no OLAP server was available, so no function was evaluated against a cube.
- The CUBEVALUE example: the standard prints its example block across a page break and shows none.
- The statistical and financial categories and the math functions outside the math page.
Sources
- ECMA-376 5th edition Part 1, research/ooxml/ecma376/p1/part1.txt: category table (line 76961), 18.17.7.65 CUBEKPIMEMBER (line 80117), .66 CUBEMEMBER (80178), .67 CUBEMEMBERPROPERTY (80226), .68 CUBERANKEDMEMBER (80258), .69 CUBESET (80291), .70 CUBESETCOUNT (80373), .71 CUBEVALUE (80390)
- [MS-OI29500] v20260818, research/ooxml/ms/MS-OI29500.txt, notes 2.1.914 to 2.1.916 (lines 18636 to 18653)
- LibreOffice, soffice headless, flat ODS to CSV: samples/xlsx/oracle/cubefn/