Read the Properties of all Measures
Make list of all the properties
We want to see what properties exist for measures in Power BI desktop. We'll use Tabular Editor for this. We already saw how to use tabular editor in this post. This time we will first read all possible properties for Measures. We can use code below to achieve that. Result will be written to CSV file.
using System.Reflection;
using System.IO;
var file = @"C:\Users\Sima\Desktop\MeasureProperties.csv";
using(var fileWriter = new StreamWriter(file))
foreach(var Property in typeof( Measure ).GetTypeInfo().GetProperties() )
{
fileWriter.Write( Property.Name + "\n" );
}
We will get 36 properties.
Annotations | DataCategory | DataType | DaxObjectFullName | DaxObjectName | DaxTableName |
DependsOn | Description | DetailRowsExpression | DisplayFolder | ErrorMessage | Expression |
ExtendedProperties | FormatString | InPerspective | IsHidden | IsRemoved | IsSimpleMeasure |
IsVisible | KPI | LineageTag | MetadataIndex | Model | Name |
NeedsValidation | ObjectType | ObjectTypeName | Parent | ReferencedBy | SourceLineageTag |
State | Synonyms | Table | TranslatedDescriptions | TranslatedDisplayFolders | TranslatedNames |
I highlighted, with blue color, properties that return more than one value. For example "Synonyms" could have several strings. With green background color I highlighted properties that I don't know what are. We will still try to read their values. Pink color is for properties that will return objects. We already have property DaxTableName that will give us name of a table measure belongs to. For that reason pink color properties (Table, Parent, Model) are not so useful for us.
Get values for all the properties
![]() | We have one table "SampleTable" with only one column "Col1" (1). In this table we have four measures that are interdependent (3). We will mostly focus our attention to Measure2 (4). For this measure we will change some of the properties so that we have something to work with (5). |
Now we can use code to read values of all of this properties. You can find this code in download files for this post. In the table below we can see result of a code for our sample table. Not all of the properties are shown. Notice the property "DependsOn". This property will list all the objects our measure is depending on. Similar property is "ReferencedBy". This property will show all the objects that reference our measure. This two properties are part of Tabular Editor and you will not find them if you use Visual Studio.
Measure | Property | Value | | | Measure | Property | Value |
---|---|---|---|---|---|---|
Measure2 | DataType | Int64 | | | Measure2 | Expression | [Measure1] + 1 |
Measure2 | DaxObjectFullName | [Measure2] | | | Measure2 | FormatString | #.##0,00 |
Measure2 | DaxTableName | 'SampleTable' | | | Measure2 | IsHidden | FALSE |
Measure2 | DependsOn | [Measure1] | | | Measure2 | IsVisible | TRUE |
Measure2 | DependsOn | 'SampleTable' | | | Measure2 | Name | Measure2 |
Measure2 | DependsOn | 'SampleTable'[Col1] | | | Measure2 | ReferencedBy | [Measure3] |
Measure2 | Description | Measure2Description | | | Measure2 | ReferencedBy | [Measure4] |
Measure2 | DisplayFolder | Measure2DisplayFolder | | | Measure2 | Synonims | Measure2Synonym1, Measure2Synonym2 |
Sample PBIX file and Tabular Editor code can be downloaded here: