# Cube.Dimensions

## What is the Cube.Dimensions Function?

The Cube.Dimensions function is used to retrieve the dimensions of a cube from a given connection. It takes a single argument, which is the connection to the cube. The function returns a table that contains information about the dimensions in the cube.

## How Does it Work?

The Cube.Dimensions function works by sending an MDX query to the cube to retrieve information about the dimensions. The MDX query is constructed using the M language, which is the language used by Power Query.

The M code behind the Cube.Dimensions function is relatively simple. It starts by creating a new connection to the cube using the given connection string. Once the connection is established, the function sends an MDX query to the cube to retrieve information about the dimensions.

The MDX query used by the Cube.Dimensions function is as follows:

SELECT {[DIMENSION_NAME]} ON COLUMNS FROM [CUBE_NAME];

``` In this query, [DIMENSION_NAME] is the name of the dimension that you want to retrieve information about, and [CUBE_NAME] is the name of the cube that you want to retrieve the information from. The query returns a table that contains information about the dimension. This information includes the name of the dimension, the number of hierarchies in the dimension, and the number of members in each hierarchy. Example Usage Here is an example of how you can use the Cube.Dimensions function to retrieve information about the dimensions in a cube: ```

let

Source = AnalysisServices.Database(“localhost”, “Adventure Works DW”),

Dimensions = Cube.Dimensions(Source{[Name=”Adventure Works DW”]}[Data])

in

Dimensions

``` In this example, we first create a new connection to the Adventure Works DW cube. We then use the Cube.Dimensions function to retrieve information about the dimensions in the cube. The resulting table contains information about all of the dimensions in the Adventure Works DW cube. The Cube.Dimensions function is a powerful tool that can be used to retrieve information about the dimensions in a cube. It works by sending an MDX query to the cube and returning a table that contains information about the dimensions. By understanding the M code behind this function, you can better understand how it works and how to use it in your own projects. Power Query and M Training Courses by G Com Solutions (0800 998 9248) Power Query and M Intensive Training Course £1,050.00 – £26,550.00 Select optionsContinue Loading Done Power Query and M Introduction £395.00 – £9,750.00 Select optionsContinue Loading Done Power Query and M Intermediate £395.00 – £9,750.00 Select optionsContinue Loading Done Power Query and M Advanced £395.00 – £9,750.00 Select optionsContinue Loading Done Upcoming Courses Contact Us Subject Your Name (required) Company/Organisation Email (required) Telephone Training Course(s) Power BI Intensive TrainingPower BI introduction Power BI IntermediatePower BI AdvancedDAXPower Query MPower BI CertificationPower BI AdministrationPower PlatformPower AutomatePower AppsOTHER Your Message Upload Example Document(s) (Zip multiple files) ```
``` ```
``` ```
``` ```
``` ```
``` ```