Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
12k views
in Power BI by 26 30 35
reshown by

In Power BI desktop, I am trying to use RELATED DAX function in a Measure but I got this error "The column either doesn't exist or doesn't have a relationship to any table available in the current context.

use the RELATED() DAX function with a Measure in Power BI

 Is it possible to use the RELATED() DAX function with a Measure in Power BI?


1 Answer

1 like 0 dislike
by 158 185 373
selected by
 
Best answer

Is it possible to use the RELATED() DAX function with a Measure in Power BI?

As per the official Microsoft documentation, the RELATED function needs a row context; therefore, it can only be used in calculated column expression, where the current row context is unambiguous, or as a nested function in an expression that uses a table scanning function. A table scanning function, such as SUMX, gets the value of the current row value and then scans another table for instances of that value.

use related function in a measure in Power BI

So in your Measure, if you are using the CALCULATE function that removes the row context, you will not be able to use the RELATED function because the row context is no longer available, and in this case, you have to use the Filter expression to define the row context and to be able to use the RELATED function as below:

Measure = calculate( sum('Product List'[Sold]),FILTER('Product List', RELATED('Product Price (RELATED)'[ProductKey]) = 1 ))

Alternatively, you can create a calculated column that holds the related value,

Calculated Column(RELATED) = RELATED('Product Price (RELATED)'[Price])

Then use this column in your Measure as below:

Measure = sum('Product List'[Calculated Column(RELATED)])

Read more at Power BI: RELATED Vs LOOKUPVALUE DAX

by 26 30 35
0 0
So I can use the related function just in filter expression measure, Right?
by 158 185 373
0 0
Yes. it's correct!
If you don’t ask, the answer is always NO!
...