A DAX expression containing syntax errors stops the execution of the calculation. These errors are highlighted during development, so they should not affect a report. Errors appearing in valid expressions are different and not discussed here.
A syntax error is displayed with a yellow warning symbol appearing below the DAX expression.
The message should help the author fix the code, but sometimes the text suggests a possible action without describing the underlying issue. The goal of this article is to explain the more common DAX error messages by providing a more detailed explanation and by including links to additional material. If some terms are not clear, look at the linked articles or consider some free self-paced training such as Introducing DAX.
Missing row context (1)
The following measure displays a very common error.
Sales Error1 := Sales[Quantity] * Sales[Net Price]
A single value for column ‘Quantity’ in table ‘Sales’ cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
Short translation: The Sales[Quantity] column reference does not have a row context.
From a DAX standpoint, the expression included in the measure has two column references (Sales[Quantity] and Sales[Net Price]) which cannot be evaluated because the measure does not provide a row context. The row context is only available in calculated columns and in the expression written in an iterator, such as SUMX, MINX, FILTER, ADDCOLUMNS, and so on.
The first part of the error message is misleading. Indeed, it seems that a single value cannot be determined because more than one row of the Sales table is active in the filter context. This is not true, because the same error message would appear even if the Sales table had only one row.
The second sentence in the error message provided by Power BI provides a suggestion that would not be immediately applicable in this formula. SUM ( table[column] ) is a syntax that is valid because SUM accepts a single column reference, but multiplying the results of the sum of the two columns is not what the author is looking to achieve. Probably, the intended result is the sum of the product between Quantity and Net Price for every row of the Sales table active in the filter context.
Therefore, the right syntax is:
SUMX ( Sales, Sales[Quantity] * Sales[Net Price] )
SUM ( Sales[Quantity] )
internally corresponds to the following SUMX version:
SUMX ( Sales, Sales[Quantity] )
Missing row context (2)
Another case of a missing row context is the following measure:
Sales Error2 := SUMX ( Sales, Sales[Quantity] * 'Product'[Unit Price] )
A single value for column ‘Unit Price’ in table ‘Product’ cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
This is the same error as in the previous section. The only reason we use a second example for this case is because here, the row context does exist – but not for the right table. Moreover, the presence of this error message clarifies that the Product[Unit Price] column does exist, but cannot be reached. Therefore, do not waste time checking whether the column name is right; the problem is the absence of the row context. If the Product[Unit Price] column were part of the expanded table Sales, then RELATED could fix the formula.
SUMX ( Sales, Sales[Quantity] * RELATED ( 'Product'[Unit Price] ) )
In this case the suggestion about using an aggregation is completely irrelevant. Indeed, what is needed is to retrieve the right row from a related table. Although the error message is the same, the solution is completely different.
Wrong column reference
This measure tries to reach a column that does not exist.
Sales Error3 := SUMX ( Sales, Sales[Quantity] * 'Product'[Unt Price] )
Column ‘Unt Price’ in table ‘Product’ cannot be found or may not be used in this expression.
In this case the Product[Unt Price] column does not exist anywhere in the data model. This error message is different from the one described in the previous row section, which only appears when there is a column reference to an existing column that cannot be reached. The fix for this error message is to find the right column name in case it has been misspelled. Clearly, by using the following syntax the error message will change because now there is a missing row context issue again:
SUMX ( Sales, Sales[Quantity] * 'Product'[Unit Price] )
The goal of this example was to clarify the different error message between a wrong column reference and a missing row context.
Wrong measure reference
The following measure tries to reference a measure that does not exists.
Sales Error4 = [Sales Amnt]
The value for ‘Sales Amnt’ cannot be determined. Either ‘Sales Amnt’ doesn’t exist, or there is no current row for a column named ‘Sales Amnt’.
The error message is similar to the one displayed for a wrong column reference. Those who follow the best practices in naming columns and measure references can trust the different error messages. The ones without a table name are related to missing measures (like in this example), whereas the ones that include a table name in the error message are related to missing columns. By not following best practices, it also becomes harder to understand the error message; indeed, it is not clear whether the problem is for a column or for a measure.
In this example, the solution is to fix the measure name:
Sales Error4 = [Sales Amount]
DAX error messages might be hard to interpret. Pay attention to the details and use this article as a guide to find the proper action to fix the code of the formula.
Returns the sum of an expression evaluated for each row in a table.
SUMX ( <Table>, <Expression> )
Returns the smallest value that results from evaluating an expression for each row of a table. Strings are compared according to alphabetical order.
MINX ( <Table>, <Expression> )
Returns a table that has been filtered.
FILTER ( <Table>, <FilterExpression> )
Returns a table with new columns specified by the DAX expressions.
ADDCOLUMNS ( <Table>, <Name>, <Expression> [, <Name>, <Expression> [, … ] ] )
Adds all the numbers in a column.
SUM ( <ColumnName> )