A for Analytics

A For Analytics

DAX Power BI: An Overview of DAX Guide and DAX Studio

DAX Power BI: An Overview of DAX Guide and DAX Studio

Data Analysis Expressions (DAX) is a formula expression language that is utilized in Analysis Services, Power BI, and Power Pivot in Excel. DAX enables advanced calculations and queries to be performed on data in related tables and columns in tabular data models by using functions, operators, and values.

This article offers a fundamental overview of the key concepts in DAX that are applicable to all products that use it. It’s important to note that some functionality may not be relevant to certain products or use cases. It’s recommended to refer to the specific documentation of your product to learn about its particular implementation of DAX Power BI.

Calculations

DAX Power BI formulas are used in measures, calculated columns, calculated tables, and row-level security.

Mearsures

The article discusses Measures, which are dynamic calculation formulas used in reporting to support filtering model data by multiple attributes. Measures are created using the DAX formula bar and can use standard aggregation functions or custom formulas. However, the results of a measure cannot be immediately output without context, as each cell requires a separate query to evaluate the expression based on its relevant data subset, which varies with different row and column headers or slicers and filters in a reporting client application.

DAX
Total Sales = SUM([Sales Amount])

In a report, when a user adds the TotalSales measure and the Product Category column from a Product table into Filters, the Sales Amount sum is computed and presented for each product category.

Measures have a different syntax than calculated columns and require the measure’s name to precede the formula. In the above example, the formula is preceded by the name Total Sales. Once created, the measure’s name and definition will be displayed in the reporting client application’s Fields list, and will be available to all model users based on perspectives and roles.

Calculated columns

A calculated column is a new column that can be added to an existing table in the model designer. It is created by defining a DAX formula that determines the values for each row in the column. When a valid DAX formula is entered into the formula bar, values for each row in the table are immediately calculated and stored in the in-memory data model.

For instance, let’s say we have a Date table. By entering a formula in the calculated column, we can create a new column that displays the year and quarter of each date. To do this, we use values from the Calendar Year and Calendar Quarter columns in the same table, adding a space and the capital letter “Q” to combine them into a single string value.

DAX
= [Calendar Year] & " Q" & [Calendar Quarter]

These values are computed for each row in the table, and the resulting values for the calculated column are displayed immediately. For example, if the original date was in the first quarter of 2017, the new calculated column would display “2017 Q1”.

It’s worth noting that column values are only recalculated if the table or any related table is refreshed, or if the entire model is unloaded and reloaded. This means that any changes made to the data in the underlying table will not automatically update the calculated column unless the table is refreshed or the model is reloaded.

Calculated tables

A calculated table is a type of computed object that is created based on a formula expression, derived from one or more existing tables within the same model. Instead of retrieving values from a data source, the values in the new table are defined by a DAX Power BI formula.

Calculated tables can be particularly useful when dealing with role-playing dimensions. For instance, the Date table can be used as OrderDate, ShipDate, or DueDate, depending on the foreign key relationship. By creating a calculated table for ShipDate, you can have a standalone table that can be queried and operated on just like any other table. They are also beneficial when creating a filtered rowset, or a subset/superset of columns from an existing table while keeping the original table intact for other scenarios.

Calculated tables can establish relationships with other tables, and their columns can have data types, formatting, and data categories. Calculated tables can be named and can be surfaced or hidden just like any other table. They are also recalculated whenever the tables they depend on are refreshed or updated.

Row-level security

When using row-level security in a DAX formula, the formula must evaluate to a Boolean TRUE/FALSE condition that determines which rows can be returned in a query by members of a particular role. For example, for members of the Sales role, the Customers table can be restricted to show only data for customers located in the USA, and any aggregates (such as SUM) will only apply to these USA customers.

It’s important to note that row-level security is not available in Power Pivot in Excel. When creating an allowed row set with a DAX power BI formula, you are not denying access to other rows; rather, they are simply not returned as part of the allowed row set. Other roles can still allow access to the rows excluded by the DAX formula. If a user is a member of another role that allows access to a particular row set, they can view the data for that row.

Row-level security formulas also apply to related rows. When a table has multiple relationships, filters will apply security for the active relationship. Row-level security formulas will be intersected with other formulas defined for related tables.

DAX
= Customers[Country] = "USA"

Queries

DAX queries can be executed using various tools such as SQL Server Management Studio (SSMS) or DAX Studio, an open-source application available at daxstudio.org. While DAX calculation formulas are restricted to tabular data models, DAX queries can also be utilized with Analysis Services Multidimensional models. Compared to Multidimensional Data Expressions (MDX) queries, DAX queries are often more efficient and easier to compose.

Similar to a SELECT statement in T-SQL, a DAX query is a statement. The simplest form of a DAX query is an “evaluate” statement, which can be written as follows:

DAX
EVALUATE
 ( FILTER ( 'DimProduct', [SafetyStockLevel] < 200 ) )
ORDER BY [EnglishProductName] ASC

Returns in Results a table listing only those products with a SafetyStockLevel less than 200, in ascending order by EnglishProductName.

You can create measures as part of the query. Measures exist only for the duration of the query.

Formulas

DAX formulas play a crucial role in creating calculations for calculated columns and measures, as well as ensuring data security through row-level security. If you want to create formulas for calculated columns and measures, you can use the formula bar at the top of the model designer window or the DAX Editor. On the other hand, to create formulas for row-level security, you can utilize the Role Manager or Manage roles dialog box.

The information presented in this section aims to provide a fundamental understanding of DAX formulas, and it is intended to serve as a starting point for those who are new to this topic.

Formula basics

In creating DAX formulas, there is a wide range of complexity that can be used. Here are some examples of simple formulas that can be used in a calculated column:

FormulaDefinition
= TODAY()Inserts today’s date in every row of a calculated column.
= 3Inserts the value 3 in every row of a calculated column.
= [Column1] + [Column2]Adds the values in the same row of [Column1] and [Column2] and puts the results in the calculated column of the same row.

Regardless of whether the formula is simple or complex, the following steps can be used when building a formula:

  1. Each formula must begin with an equal sign (=).

  2. You can either type or select a function name, or type an expression.

  3. Begin to type the first few letters of the function or name you want, and AutoComplete displays a list of available functions, tables, and columns. Press TAB to add an item from the AutoComplete list to the formula.

  4. You can also click the Fx button to display a list of available functions. To select a function from the dropdown list, use the arrow keys to highlight the item, and click OK to add the function to the formula.

  5. Supply the arguments to the function by selecting them from a dropdown list of possible tables and columns, or by typing in values.

  6. Check for syntax errors: ensure that all parentheses are closed and columns, tables and values are referenced correctly.

  7. Press ENTER to accept the formula.

In this example, let’s look at a formula in a measure named Days in Current Quarter:
DAX
Days in Current Quarter = COUNTROWS( DATESBETWEEN( 'Date'[Date], STARTOFQUARTER( LASTDATE('Date'[Date])), ENDOFQUARTER('Date'[Date])))

The proportion of an incomplete period compared to the previous period can be calculated using a specific formula that takes into account the proportion of time that has elapsed. To calculate this, one can use the ratio of the number of days in the current quarter that have elapsed to the total number of days in the current quarter.

Here are the different elements of this formula:

Formula ElementDescription
Days in Current QuarterThe name of the measure.
=The equals sign (=) begins the formula.
[Days Current Quarter to Date]/[Days in Current Quarter]Gives the proportion elapsed in the current period.
COUNTROWS()COUNTROWS counts the number of rows in the Date table.
DATESBETWEEN(‘Date'[Date], STARTOFQUARTER(‘Date'[Date]), LASTDATE(‘Date'[Date]))The DATESBETWEEN function returns the dates between the last date for each value in the Date column in the Date table.
‘Date’Specifies the Date table. Tables are in single quotes.
[Date]Specifies the Date column in the Date table. Columns are in brackets.
,Comma separates the arguments of the DATESBETWEEN function.
STARTOFQUARTER(‘Date'[Date])The STARTOFQUARTER function returns the date of the start of the quarter.
LASTDATE(‘Date'[Date])The LASTDATE function returns the last date of the quarter.
ENDOFQUARTER(‘Date'[Date])The ENDOFQUARTER function returns the date of the end of the quarter.

Using formula AutoComplete

Formula AutoComplete is a feature that assists you in entering a correct formula syntax by presenting options for each element of the formula. This tool can be used even when working with nested functions in the middle of an existing formula.

As you begin typing, the text immediately preceding the insertion point will be displayed as values in a drop-down list. All text after the insertion point remains unaltered.

It is important to note that AutoComplete does not automatically add the closing parenthesis of functions or match them. Therefore, it is necessary to ensure that each function is syntactically accurate; otherwise, the formula will not be usable or savable.

Using multiple functions in a formula

Functions can be nested, allowing the output of one function to serve as the input for another. In calculated columns, it is possible to nest up to 64 levels of functions. However, excessive nesting can make formula creation and troubleshooting more challenging.

Some functions are specifically designed for use as nested functions, returning a table as their output. It is important to note that these tables cannot be directly saved as a result, but must instead be provided as input to a table function. For instance, the functions SUMX, AVERAGEX, and MINX all require a table as their first argument.

Functions

A function is a named expression that performs calculations and returns a value when executed. In most cases, functions have both required and optional arguments, also known as parameters, that are used as input. DAX Power BI provides a range of functions that can be used to perform various calculations based on dates and times, create conditional values, manipulate strings, perform lookups based on relationships, and iterate over tables to perform recursive calculations.

Although DAX functions may look similar to Excel formulas, there are several important differences to consider. Firstly, DAX functions always reference a complete column or a table, unlike Excel which can use individual cell references. However, you can filter the table or column to select only certain values for use in your formula.

If you need to perform customized calculations on a row-by-row basis, DAX provides functions that allow you to use the current row value or a related value as a parameter, enabling you to perform calculations that vary by context. To better understand how these functions work, it is important to understand the concept of Context.

DAX Popwer BI includes many functions that return a table, rather than a value. Although these tables are not displayed in reporting clients, they can be used as input for other functions. For example, you can retrieve a table and then count the distinct values in it, or calculate dynamic sums across filtered tables or columns.

DAX functions also provide a range of time intelligence functions that let you define or select date ranges, and perform dynamic calculations based on these dates or ranges. With these functions, you can compare sums across parallel periods or create other time-based calculations to suit your needs.

Aggregation functions

Aggregation functions are utilized to calculate a single value, such as count, sum, average, minimum, or maximum, for all rows within a column or table based on a specified expression.

Date and time functions

DAX’s date and time functions are similar to those found in Microsoft Excel. However, they rely on a datetime data type that began on March 1, 1900.

Filter functions

Filter functions in DAX allow for the retrieval of specific data types, searching for related table values, and filtering by related values. Lookup functions function in a similar way to databases by using tables and relationships, while filtering functions permit the manipulation of data context for dynamic calculations.

Financial functions

Financial functions are used in DAX formulas that perform financial calculations, such as net present value and rate of return, and are similar to those found in Microsoft Excel.

Information functions

Information functions evaluate the cell or row provided as an argument and indicate whether the value matches the anticipated type. For instance, the ISERROR function returns TRUE if the referenced value contains an error.

Logical functions

Logical functions work on expressions to provide information about the expression’s values. For instance, the TRUE function indicates whether the expression being evaluated returns a TRUE value.

Mathematical and trigonometric functions

DAX’s mathematical and trigonometric functions are very similar to those found in Excel, with some minor differences in the numeric data types used.

Other functions

Other functions are used for unique actions that do not fit into any of the other function categories.

Relationship functions

Relationship functions in DAX allow for the return of values from another related table, specification of a particular relationship to use in an expression, and specification of cross-filtering direction.

Statistical functions

Statistical functions calculate values associated with statistical distributions and probability, such as standard deviation and the number of permutations.

Text functions

Text functions in DAX are very similar to those found in Excel. They allow for the return of a portion of a string, search for text within a string, or concatenate string values. DAX  Power BI also provides functions for controlling the formats for dates, times, and numbers.

Time intelligence functions

DAX’s time intelligence functions enable the creation of calculations that utilize built-in knowledge of calendars and dates. By combining time and date ranges with aggregations or calculations, meaningful comparisons across comparable time periods for sales, inventory, and other variables can be built.

Table manipulation functions

Table manipulation functions return a table or manipulate existing tables. ADDCOLUMNS allows for the addition of calculated columns to a specified table, while SUMMARIZECOLUMNS can return a summary table over a set of groups.

Variables

An expression can contain variables that are created using the keyword VAR. Unlike a function, VAR is not a function but a keyword used to assign a name to the result of an expression. The named variable can then be used as an argument in other measure expressions. Consider the following example:

DAX
VAR
    TotalQty = SUM ( Sales[Quantity] )

Return

    IF (
        TotalQty > 1000,
        TotalQty * 0.95,
        TotalQty * 1.25
        )

One can pass TotalQty as a named variable to other expressions in the given example. It is important to note that variables can be of any scalar data type, which also includes tables. The utilization of variables in DAX formulas holds immense power and can greatly enhance their functionality.

Data types

Data Types in Tabular Models and DAX Power

Data Type in ModelData Type in DAXDescription
Whole Number64 bit (eight-bytes) integer valueNumbers that have no decimal places. Integers can be positive or negative numbers, but must be whole numbers between -9,223,372,036,854,775,808 (-2^63) and 9,223,372,036,854,775,807 (2^63-1).
Decimal Number64 bit (eight-bytes) real numberReal numbers are numbers that can have decimal places. Real numbers cover a wide range of values: Negative values from -1.79E+308 through -2.23E-308; Zero; Positive values from 2.23E-308 through 1.79E+308. However, the number of significant digits is limited to 17 decimal digits.
BooleanBooleanEither a True or False value.
TextStringA Unicode character data string. Can be strings, numbers or dates represented in a text format.
DateDate/timeDates and times in an accepted date-time representation. Valid dates are all dates after March 1, 1900.
CurrencyCurrencyCurrency data type allows values between -922,337,203,685,477.5808 to 922,337,203,685,477.5807 with four decimal digits of fixed precision.
N/ABlankA blank is a data type in DAX that represents and replaces SQL nulls. You can create a blank by using the BLANK function, and test for blanks by using the logical function, ISBLANK.
TableTableThe Table data type is the input or output to many DAX functions. For example, the FILTER function takes a table as input and outputs another table that contains only the rows that meet the filter conditions. By combining table functions with aggregation functions, you can perform complex calculations over dynamically defined data sets.

When importing data into a model, the data is converted to one of the tabular model data types. The data types supported by the source can vary, but the imported data will be converted to one of the tabular model data types. When performing calculations, the data is then converted to a DAX data type for the duration and output of the calculation. When creating a DAX formula, the data type returned is automatically determined by the terms used in the formula.

It is essential to understand the data types and their application, especially in DAX formulas, as errors in formulas or unexpected results may occur when using a particular operator that cannot be used with a data type specified in an argument. For instance, the formula = 1 & 2 returns a string result of 12, whereas = “1” + “2” returns an integer result of 3.

Context

When crafting DAX formulas, having a grasp of the concept of context is essential. Context facilitates dynamic analysis, allowing formula results to adapt based on the current row or cell selection and any related data. A solid understanding of context and its effective utilization are crucial in developing high-performance, dynamic analyses and diagnosing issues in formulas.

Tabular models’ formulas can be assessed in distinct contexts, based on other design components, such as:

  1. Filters that are implemented in a report or PivotTable.
  2. Filters that are defined within the formula itself.
  3. Relationships established using specialized functions within the formula.

Context can be categorized into different types, including row context, query context, and filter context.

Row context

Row context refers to the current row in a table or a specific subset of data in a table. When a formula is created in a calculated column, the row context for that formula includes all the values from columns in the current row. This means that if there are any related tables, the formula will also include all the values from those tables that are associated with the current row.

To illustrate, let’s say you create a calculated column that adds values from two columns – Freight and Tax – in the same table. The formula will automatically retrieve only the values from the current row in those columns.

The row context also considers any relationships established between tables, including those defined within a calculated column using DAX formulas. This helps to determine which rows in related tables are associated with the current row.

For instance, if you want to fetch the tax value from a related table based on the region that the order was shipped to, you can use the RELATED function. This function retrieves the tax rate for the current region from the related table and adds it to the value of the Freight column. The formula does not require you to specify the specific relationship that connects the tables in DAX formulas.

In summary, row context is the current row or subset of data in a table, and any formula created in a calculated column will include the values from all columns in the current row. Additionally, row context follows any relationships between tables to determine which rows in related tables are associated with the current row.

DAX
= [Freight] + RELATED('Region'[TaxRate])

Multiple row context

DAX, a powerful formula language in Power BI, offers a range of functions that enable iterative calculations over tables. These functions operate on multiple current rows, each with its own row context, allowing you to create formulas that perform recursive operations over an inner and outer loop.

To illustrate, let’s say you have a Products table and a Sales table in your model. You want to find the maximum quantity ordered for each product in any transaction in the Sales table, which contains data on multiple transactions involving various products.

Using DAX Power Bi, you can construct a single formula that accurately computes the desired value. What’s more, the formula will automatically update whenever new data is added to the tables, ensuring the results are always up-to-date.

DAX
= [Freight] + RELATED('Region'[TaxRate])

The EARLIER function is used to retain the row context from the previous operation in a calculation. To see a specific instance of this formula, please refer to the EARLIER example.

In essence, this function keeps track of two sets of context in memory: one set corresponds to the current row for the inner loop of the formula, while the other set pertains to the current row for the outer loop of the formula. DAX seamlessly passes values between these two loops, enabling you to construct intricate aggregates.

Query context

The concept of query context pertains to the portion of data that is implicitly retrieved for a given formula. When a user includes a measure or field in a report, the system considers row and column headers, slicers, and report filters to determine the context. The necessary queries are then executed against the model data to obtain the appropriate subset of data, perform the calculations specified by the formula, and ultimately populate values in the report.

Since the context varies depending on where the formula is placed, the outcome of the formula may differ as well. For instance, suppose a formula is created to sum the values in the Profit column of the Sales table: = SUM(‘Sales'[Profit]). If this formula is utilized in a calculated column within the Sales table, the formula’s results will remain the same throughout the table because the query context for the formula always encompasses the entire dataset of the Sales table. Consequently, the outcomes will display the profit for all regions, all products, all years, and so forth.

However, users generally prefer not to view the same result numerous times. Instead, they want to view the profit for a specific year, a specific country, a specific product, or a combination of these criteria, followed by a grand total.

In a report, the context is altered by filtering, adding or removing fields, and using slicers. For each modification, the measure’s query context is evaluated differently. Therefore, the same formula employed in a measure is appraised in a distinct query context for each cell.

Filter context

Filter context refers to the set of allowed values in each column or in the retrieved values from a related table. You can apply filters to the column in the designer or in the presentation layer like reports and PivotTables. Furthermore, you can define filters explicitly by filter expressions within the formula.

When you specify filter constraints on the set of values allowed in a column or table using arguments to a formula, filter context is added. This context applies on top of other contexts, such as row context or query context.

In tabular models, there are various ways to create filter context. Clients that consume the model, such as Power BI reports, allow users to create filters dynamically by adding slicers or report filters on the row and column headings. You can also specify filter expressions directly within the formula to filter tables used as inputs, specify related values, or dynamically obtain context for the values used in calculations. Additionally, you can completely clear or selectively clear the filters on specific columns. This is particularly useful when creating formulas that calculate grand totals.

To learn more about creating filters within formulas, you can refer to the FILTER Function (DAX). For an example of how filters can be cleared to create grand totals, check out the ALL Function (DAX). Finally, for examples of selectively clearing and applying filters within formulas, you can see ALLEXCEPT.

Determining context in formulas

When you create a DAX formula, the formula undergoes a validation process to ensure that it contains valid syntax. Then, it is checked to confirm that the names of the tables and columns included in the formula can be located within the current context. If any specified column or table is not found, an error message is returned.

The current context during validation (and recalculation operations) is determined by utilizing the tables available in the model, any relationships between those tables, and any applied filters, as explained in the preceding sections.

For instance, if you have just imported data into a new table that is not related to any other tables, and no filters have been applied, the current context encompasses the entire set of columns in that table. However, if the table is linked by relationships to other tables, the current context includes the related tables. Furthermore, if you add a column from the table to a report containing slicers and report filters, the context for the formula is the subset of data in each cell of the report.

Context is a powerful concept that can also make it challenging to troubleshoot formulas. We recommend starting with simple formulas and relationships to understand how context works. The following section provides some examples of how formulas use different types of context to dynamically return results.

Operators

In DAX language, formulas employ four distinct types of calculation operators:

  1. Comparison operators enable comparison of values and generate a logical TRUE\FALSE value as the output.
  2. Arithmetic operators carry out arithmetic calculations that generate numeric values as the result.
  3. Text concatenation operators combine two or more text strings.
  4. Logical operators merge two or more expressions to produce a single result.

For comprehensive details regarding the operators used in DAX formulas, please refer to the DAX Power BI operators.

Working with tables and columns

Tabular data models include tables that may resemble Excel tables, but they function differently in terms of working with data and formulas. In tabular models, formulas operate solely on tables and columns, and not individual cells, range references, or arrays. These formulas can also utilize relationships to retrieve values from related tables, and the retrieved values will always correspond to the current row value.

In contrast to Excel worksheets, irregular or “ragged” data is not allowed in tabular data models. Each row in a table must have the same number of columns, though certain columns may contain empty values. It’s important to note that Excel data tables and tabular model data tables are not interchangeable.

In tabular models, a data type must be set for each column, and each value within that column must adhere to that data type.

Referring to tables and columns in formulas

To reference a specific table and column, you can simply use its name. For instance, by using the fully qualified name, you can refer to columns from multiple tables, as shown in the following formula:

DAX
= SUM('New Sales'[Amount]) + SUM('Past Sales'[Amount])

When a formula is assessed, the designer of the model initially reviews the syntax in general and then compares the names of tables and columns that you have specified against the potential tables and columns in the current context. In the event that the name is ambiguous or the table or column cannot be located, an error message will be displayed instead of a data value in cells where the error occurred. To acquire a more comprehensive understanding of the naming requirements for tables, columns, and other objects, please refer to the Naming Requirements in DAX Syntax documentation.

Table relationships

When you establish connections between tables, you enable related data in other tables to be used in calculations. This means that you can create a calculated column to identify all shipping records associated with the current reseller and then sum up their shipping costs. However, in some cases, establishing a relationship may not be necessary. You can utilize the LOOKUPVALUE function in a formula to retrieve the value in result_columnName for the row that meets criteria specified in the search_column and search_value arguments.

Several DAX functions require a relationship between tables, or multiple tables, to locate the columns you have referenced and return sensible results. Some functions will try to identify the relationship, but it is advisable to establish a relationship whenever feasible for optimal outcomes. Tabular data models can accommodate multiple relationships among tables. To avoid confusion or incorrect results, only one relationship at a time is designated as the active relationship. However, you can change the active relationship as needed to navigate different connections in the data during calculations. To specify one or more relationships for a particular calculation, use the USERELATIONSHIP function.

When working with relationships, it is important to adhere to these formula design rules:

  • When tables are connected by a relationship, the two columns used as keys must have matching values. Referential integrity is not enforced, so it is possible to establish a relationship with non-matching values in a key column. In such cases, you should be aware that blank or non-matching values may affect the formula results.
  • Linking tables in your model by using relationships expands the scope or context in which your formulas are evaluated. Changes in context due to new tables, new relationships, or alterations in the active relationship can cause your results to vary in unexpected ways. To learn more, see Context in this article.

Process and refresh

When designing a model that involves complex formulas, large datasets, or data from external sources, it’s essential to understand the concepts of process and recalculation. Although they are separate operations, they are closely related.

Process or refresh is the process of updating the data in a model with new information from external data sources. It is crucial to ensure that the model always contains the latest data. However, processing can be time-consuming and can affect performance.

Recalculation, on the other hand, is the process of updating the results of formulas to reflect changes in the underlying data or changes in the formulas themselves. For example, if you change a formula in a calculated column, the values in that column must be recalculated. Recalculation can also affect performance, especially for complex models with large datasets.

For calculated columns, the values are computed and stored in the model, and updating them requires processing the entire model using one of the three processing commands: Process Full, Process Data, or Process Recalc. It’s important to note that changing a formula will always require recalculation for the entire column.

For measures, the values are dynamically evaluated whenever a user adds the measure to a PivotTable or opens a report. The results of the measure always reflect the latest data in the in-memory cache.

Row-level security formulas are not affected by processing or recalculation unless the recalculation results in a different value, which may change the queryable status of the row for role members.

In conclusion, understanding the concepts of process and recalculation is crucial when designing complex models that involve large datasets or external data sources. By carefully considering these operations, you can ensure that your model is up-to-date, performs efficiently, and accurately reflects the underlying data.

Updates

DAX Power BI, the data modeling and calculation language for Power BI, Excel, and SQL Server Analysis Services, is continually evolving to enhance its functionality. Microsoft releases new and improved functions regularly, typically on a monthly basis. Initially, online services receive updates, followed by locally installed applications such as Power BI Desktop, Excel, SQL Server Management Studio (SSMS), and Analysis Services project extension for Visual Studio (SSDT). Cumulative updates are utilized to upgrade SQL Server Analysis Services. When new functions are introduced, they are officially announced and explained in the DAX function reference coinciding with Power BI Desktop updates. However, it is important to note that not all functions are compatible with previous versions of Excel and SQL Server Analysis Services.

Troubleshooting

When defining a formula, encountering an error could be due to a syntactic, semantic, or calculation error.

Syntactic errors are relatively straightforward to resolve, typically resulting from a missing comma or parenthesis.

Semantic and calculation errors, on the other hand, are more complex and arise when the syntax is correct, but the value or column referenced in the formula is not valid in the context. Such errors can be caused by any of the following issues:

  • The formula references a non-existent column, table, or function.
  • The formula appears correct, but upon fetching the data, the data engine detects a type mismatch and throws an error.
  • The formula passes an incorrect number or type of arguments to a function.
  • The formula references a different column that has an error, and hence its values are invalid.
  • The formula refers to a column that has not yet been processed, which means it has metadata but no actual data to use for calculations.

DAX flags the entire column that contains the invalid formula in the first four cases. In the last case, DAX grays out the column to indicate that it is in an unprocessed state.

Leave a Comment

Your email address will not be published. Required fields are marked *