Cube.Dimensions

Cube.Dimensions

D

The M Code Behind the Power Query M function 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)

Upcoming Courses

Contact Us

Subject

Your Name (required)

Company/Organisation

Email (required)

Telephone

Training Course(s)

Your Message

Upload Example Document(s) (Zip multiple files)

Copyright, G Com Solutions Ltd, 2024.
Tower Bridge Business Centre, 46-48 East Smithfield, London E1W 1AW
0800 998 9248   |   9:00 a.m. till 5:30 p.m.

Connect With Me: