Please note javascript is required for full website functionality.

Blog

Power Pivot Principles: The A to Z of DAX Functions – INFO.ANNOTATIONS

7 May 2024

In our long-established Power Pivot Principles articles, we continue our series on the A to Z of Data Analysis eXpression (DAX) functions.  This week, we look at INFO.ANNOTATIONS

 

The INFO.ANNOTATIONS function

Dynamic Management Views (DMVs) are specialised queries provided by SQL Server Analysis Services (SSAS), Azure Analysis Services (AAS), and Power BI that offer an administrative view into the internal state of these systems.  DMVs are used to retrieve metadata, monitor health and performance, and diagnose problems within the database or data model.  They serve as a powerful tool for administrators and developers to gain insights into the workings of the database engine and the tabular data model, covering aspects like performance metrics, configuration settings and the structure of database objects.

The $System schema DMVs in SQL Server Analysis Services (SSAS), Azure Analysis Services (AAS), and Power BI are categorised into four [4] types, each serving specific purposes:

  • DISCOVER: requires admin privileges and provides information about the model, including details on connected sessions and environment configuration
  • DMSCHEMA: focused on data mining, offering insights for predictive analytics and pattern recognition, mainly used in SSAS/AAS
  • MDSCHEMA: targets multidimensional models, delivering metadata and structure from an MDX perspective, relevant for OLAP cubes and dimensions
  • TMSCHEMA: designed for tabular models, it provides detailed metadata about tables, columns, measures, etc., using Tabular Model Scripting Language (TMSL) information, crucial for Power BI and tabular SSAS/AAS models.

Now, we just need to write a simple DAX syntax to query those TMSCHEMA directly in DAX query View.  In this instance, we are using INFO.ANNOTATIONS function to query the TMSCHEMA_ANNOTATIONS

The INFO.ANNOTATIONS function is one of the system functions.  It employs the following syntax:

INFO.ANNOTATIONS()

This function has no parameters.

Based upon the ‘[MS-SSAS-T]: SQL Server Analysis Services Tabular Protocol’ from Microsoft (which you may access here), the Annotation object represents the application-specific name / value pairs for the parent object.  The Analysis Services server is not expected to interpret annotations.  Annotations may generally be defined as child objects of any logical metadata object in the Tabular model, as listed for the ObjectType property in the list below.

We can write this INFO.ANNOTATIONS function on DAX query view to get the same information on the TMSCHEMA_ANNOTATIONS:

It will query the $SYSTEM.TMSCHEMA_ANNOTATIONS and return an entire table with six [6] columns:

  • ID: this represents a reference to the object
  • ObjectID: this is an ID_based reference to the object
  • ObjectType: this represents the date type of the object specified by ObjectID.  The possible values are as follows:
    • TM_TYPEID_Model (1)
    • TM_TYPEID_DataSource (2)
    • TM_TYPEID_Table (3)
    • TM_TYPEID_Column (4)
    • TM_TYPEID_AttributeHierarchy (5)
    • TM_TYPEID_Partition (6)
    • TM_TYPEID_Relationship (7)
    • TM_TYPEID_Measure (8)
    • TM_TYPEID_Hierarchy (9)
    • TM_TYPEID_Level (10)
    • TM_TYPEID_KPI (12)
    • TM_TYPEID_Culture (13)
    • TM_TYPEID_LinguisticMetadata (15)
    • TM_TYPEID_Perspective (29)
    • TM_TYPEID_PerspectiveTable (30)
    • TM_TYPEID_PerspectiveColumn (31)
    • TM_TYPEID_PerspectiveHierarchy (32)
    • TM_TYPEID_PerspectiveMeasure (33)
    • TM_TYPEID_Role (34)
    • TM_TYPEID_RoleMembership (35)
    • TM_TYPEID_TablePermission (36)
    • TM_TYPEID_Variation (37): this requires compatibility level 1400 or higher
    • TM_TYPEID_Expression (41): this requires compatibility level 1400 or higher
    • TM_TYPEID_ColumnPermission (42): this requires compatibility level 1400 or higher
    • TM_TYPEID_CalculationGroup (46): this requires compatibility level 1500 or higher
    • TM_TYPEID_QueryGroup (51): this requires compatibility level 1500 or higher.
  • Name: this represents the name of the object
  • Value: this represents the value of the annotation
  • ModifiedTime:this is the time that the object was last modified.

It should be noted that:

  • it is used for querying the DMV (Dynamic Management Views) from the $System schema called TMSCHEMA where TM stands for ‘Tabular model’ and TMSCHEMA provides information from the tabular model
  • sometimes querying DMVs may fail if we do not have the appropriate permission.

 

 

Come back next week for our next post on Power Pivot in the Blog section.  In the meantime, please remember we have training in Power Pivot which you can find out more about here.  If you wish to catch up on past articles in the meantime, you can find all of our Past Power Pivot blogs here.


Newsletter