Please note javascript is required for full website functionality.

Blog

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

17 September 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.FORMATSTRINGDEFINITIONS.

 

The INFO.FORMATSTRINGDEFINITIONS 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.

In the past, if we wanted to query those $System schema DMVs we used external tools like Tabular Editors or DAX Studio to query them:

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.FORMATSTRINGDEFINITIONS function to query the TMSCHEMA_FORMAT_STRING_DEFINITIONS.

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

INFO.FORMATSTRINGDEFINITIONS()

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  FormatStringDefinition object represents a value that is calculated based on an expression.  It is a child of a CalculationItem object or a Measure object.  As a child of a CalculationItem object, it requires compatibility level 1500 or higher.  As a child of a Measure object, it requires compatibility level 1601 or higher.

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

It will query $SYSTEM.TMSCHEMA_FORMAT_STRING_DEFINITIONS and return an entire table with seven [7] columns:

  • ID: this represents a reference to the object
  • ObjectID: this is an ID-based reference to a Measure or CalculationItem object
  • ObjectType: this is the data type of the object specified by ObjectID.  The possible values are as follows:
    • TM_TYPEID_Measure (8)
    • TM_TYPEID_CaculationItem (47)
  • Expression:  this is the DAX  dynamic format string expression
  • ModifiedTime: this is the time that the object was last modified
  • State: this is a value that provides information about the state of the parent object or the container object.  The possible values are as follows:
    • Ready (1) - The object expression is queryable and has up to-date data
    • NoData (3) - Not applicable to FormatStringDefinition
    • CalculationNeeded (4) - Not applicable to FormatStringDefinition
    • SemanticError (5) - The object expression has a semantic error
    • EvaluationError (6) - Not applicable to FormatStringDefinition
    • DependencyError (7) - A dependency associated with the FormatStringDefinition object is in an error state (SemanticError, EvaluationError, or DependencyError)
    • Incomplete (8) - Not applicable to FormatStringDefinition
    • SyntaxError (9) - The calculation item has a syntax error in its expression
  • ErrorMessage: this is a string that explains the error state that is associated with the FormatStringDefinition object.  The ErrorMessage property is set by the engine only when the state of the object is one of these three values: SemanticError, DependencyError or SyntaxError.

Here are a few remarks about function come with INFO prefix:

  • it is used for querying the DMV (Dynamic Management Views) from the $System schema.
  • 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