Excel - CUBESET Function



CUBESET Function

The Excel CUBESET function defines a combined set of tuples/members and broadcasts an expression to the cube. It is generally used with the OLAP, which retrieves the resultant set after evaluating this function. Contrary to the logical and statistical functions, you cannot directly execute the Cube functions in Excel. First, you must create a pivot table and connect it to the data model. After that, you can employ the Cube functions like CUBESET, CUBEMEMBER, CUBEVALUE functions, etc.

Compatibility

This advanced excel function is compatible with the following versions of MS-Excel −

  • Excel for Microsoft 365
  • Excel for Microsoft 365 for Mac
  • Excel for the web
  • Excel 2021
  • Excel 2021 for Mac
  • Excel 2019
  • Excel 2019 for Mac
  • Excel 2016
  • Excel for iPad
  • Excel Web App
  • Excel for iPhone
  • Excel for Android tablets
  • Excel for Android phones

Syntax

The syntax of CUBESET function is as follows −

CUBESET (connection, set_expression, [caption], [sort_order], [sort_by])

Arguments

You can use the following arguments with the CUBESET function −

Argument Description Required / Optional
Connection It specifies the connection name in the form of the string for the cube. Required
set_expression

A text string of a set expression that results in a set of members or tuples.

OR

A cell reference to an Excel range that contains one or more members, tuples, or sets included in the set.

Required
Caption A text string that is displayed in the cell instead of the caption, if one is defined, from the cube. Optional
sort_order It specifies the integer value range from 0 to 6 and denotes the sort type whose description is showcased below table: Optional
sort_by

It denotes a string value by which to sort.

For Example

To get the region with the highest production, set_expression denotes a set of regions, and sort_by represents the production measure.

Optional

The given table represents the sort of type to conduct if the sort_order argument is given −

Integer Enumerated constant Description Argument - Sort_by
0 SortNone No sorting is taken place in the specified set. Ignored
1 SortAscending Ascending order sorting is to take place in a set order by sort_by argument. Required
2 SortDescending Descending order sorting is to take place in a set order by sort_by argument. Required
3 SortAlphaAscending The set would be sorted through alpha ascending order. Ignored
4 Sort_Alpha_Descending The set would be sorted through Alpha descending order. Ignored
5 Sort_Natural_Ascending Natural ascending order is to be taken place to sort set. Ignored
6 Sort_Natural_Descending Natural descending order is to take place to sort set. Ignored

The default value is 0. An alpha sort for a set of tuples sorts on the last element in each tuple.

Points to Remember

  • Whenever you execute the CUBESET function in Excel, it quickly showcases a "#GETTING_DATA" message in the specific cell before the result is fetched.
  • If the connection name is an invalid workbook, the CUBEMEMBER function will return a #NAME Error. If the availability of the Online Analytical Processing (OLAP) server is not in Excel, is not functioning, or displays an unexpected error, then the CUBEMEMBER function will retrieve a #NAME Error.
  • CUBESET returns a #N/A error value if the syntax of set_expression is incorrect or possesses more than one member with a different dimension.
  • CUBESET will return a #VALUE! error if set_expression is larger than 255 characters, the maximum length for a function parameter. You can enter the text string in a cell and provide a cell reference as the parameter if you want to utilize text strings greater than 255 characters.
  • Suppose you gave the cell reference of a session-based object; then, the CUBESET function will retrieve a #N/A error.
  • If sort_order requires sort_by, and sort_by is omitted, CUBESET returns the #VALUE! Error message.

Example of CUBESET Function

Practice the following examples to learn the use of the CUBESET function in Excel.

Step 1 − First, assume the sample table comprises three columns: Region, Network Products category, and Gross Profit.

Excel CUBESET Function 1

After that, navigate to the Insert tab, expand the PivotTable tile, and select the From Table/Range option from the given list.

Excel CUBESET Function 2

Step 2 − Another dialog box titled PivotTable from table or range will open. You may select a created table range, such as Table13, just adjacent to the Table/Range label, and then select the Existing Worksheet where the Pivot table will be inserted. Select the Add this data to the Data Model checkbox to analyze this table and click the OK button.

Excel CUBESET Function 3

Step 3 − In the PivotTable Fields, drag the Region column and drop it into the Rows area. Similarly, drag the Network Products category column and place it into the Rows area. Then, pull the Gross profit column and place it into the Values area as given below −

Excel CUBESET Function 4

Step 4 − Furthermore, move to the PivotTable Analyze tab and select the Convert to Formulas option.

Excel CUBESET Function 5

You may enter the formula =CUBESET("ThisWorkbookDataModel",(H16,H18),"Adapters and Optics") in the E22 cell and press Enter.

Excel CUBESET Function 6

Therefore, the resultant value is Adapters and Optics.

Excel CUBESET Function 7
Advertisements