Cube.MeasureProperty

Cube.MeasureProperty

D

The M Code Behind the Power Query M function Cube.MeasureProperty

What is Cube.MeasureProperty?

Cube.MeasureProperty is a Power Query M function that is used to retrieve the value of a measure property. A measure property is metadata associated with a measure that provides additional information about that measure. The Cube.MeasureProperty function takes two arguments:

1. The name of the measure whose property value is to be retrieved

2. The name of the property to be retrieved

The function returns the value of the specified measure property.

The M Code Behind Cube.MeasureProperty

The M code behind the Cube.MeasureProperty function is relatively simple. Here is an example of the M code for the Cube.MeasureProperty function:


let

MeasureName = “Total Sales”,

PropertyName = “Display Folder”,

Cube = Cube(“Adventure Works”),

Measure = Cube[Measures]{MeasureName},

PropertyValue = Measure[PropertyName]

in

PropertyValue


In this code, we first define the variables MeasureName and PropertyName to store the names of the measure and property, respectively. We then create a new variable called Cube and set it to the name of the cube that contains the measure. In this example, we are using the Adventure Works cube.

Next, we use the MeasureName variable to retrieve the specified measure from the cube. We do this by accessing the Measures property of the cube and then using the MeasureName variable to retrieve the specified measure.

Finally, we use the PropertyValue variable to retrieve the value of the specified property from the measure. We do this by accessing the specified property using the PropertyName variable.

Using Cube.MeasureProperty in Power Query

Now that we understand the M code behind the Cube.MeasureProperty function, let's look at how we can use this function in Power Query.

To use the Cube.MeasureProperty function in Power Query, follow these steps:

1. Open Power Query in Excel or Power BI Desktop

2. Click on the "New Source" button and select the "Analysis Services" option

3. Enter the server name and database name for the cube you want to connect to

4. Click on the "Connect" button

5. Expand the "Measures" folder in the "Fields" pane to view all measures in the cube

6. Right-click on the measure whose property value you want to retrieve and select the "View Code" option

7. Copy and paste the M code for the Cube.MeasureProperty function into the code editor

8. Replace the MeasureName and PropertyName variables with the names of the measure and property you want to retrieve, respectively

9. Click on the "Done" button to save the function

Once you have saved the function, you can use it in your Power Query formulas. For example, you could use the Cube.MeasureProperty function to retrieve the display folder for a measure and then use that display folder in a custom column formula.

The Cube.MeasureProperty function is a powerful function in Power Query that is used to retrieve the value of a measure property. Understanding the M code behind this function can help you better understand how it works and how you can use it in your Power Query formulas. By following the steps outlined in this article, you should be able to use the Cube.MeasureProperty function to retrieve the value of any measure property in your cube.

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: