March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I've worked with Power BI for many years and used LOOKUPVALUE function blissfully unaware of its hidden pitfall.
It seems that this function is not always reliable. There are cases when LOOKUPVALUE can not produce a result due to the filters it isn't able to remove.
Here is a pbix file that demonstrates the problem (uploaded to Dropbox):
I created three measures:
_projectName_LOOKUPVALUE_Wrong
_projectName_CALCULATE
_projectName_NO_CALCULATE
The second and third measures work as they should, while the first one (_projectName_LOOKUPVALUE_Wrong) can not produce a correct result when Programs[Program Name] filter is applied.
For some reason LOOKUPVALUE is not able to remove the filter from 'Programs' table. That's why the function produces incorrect result.
The picture below captures the issue.
To see the semantic model, please download pbix I provided.
My questions are:
Did I miss something that led to incorrect result? What?
Is it expected that LOOKUPVALUE not always return the correct result?
Why in documentation there is nothing that warns you that the function has such a limitation and can not be blindly trusted? Really, why?
Am I supposed to submit a ticket to Support?
SQLBI has an article on this function: https://dax.guide/lookupvalue/
I do not know how they know that "Internally LOOKUPVALUE generates this equivalent syntax:"
MS Help remains silent regarding the highlighted piece.
If it's true and internally MS removes applied filters using the line: ALL ( <Table_Result_ColumName> )
then it explains everything.
But why they remove filters with this line?
Why not REMOVEFILTERS() ?
So, in my case ALL ( <Table_Result_ColumName> ) does not remove a filter from 'Programs' table.
Solved! Go to Solution.
Hi @Sergiy
_projectName_LOOKUPVALUE_Fixed =
VAR LookupProjectID =
SELECTEDVALUE('Dependencies'[ProjectId])
RETURN
CALCULATE (
LOOKUPVALUE(
Projects[Project Name],
Projects[Id],
LookupProjectID
),
ALLCROSSFILTERED ( Projects )
)
What would I take away from this?
Hi @Sergiy
_projectName_LOOKUPVALUE_Fixed =
VAR LookupProjectID =
SELECTEDVALUE('Dependencies'[ProjectId])
RETURN
CALCULATE (
LOOKUPVALUE(
Projects[Project Name],
Projects[Id],
LookupProjectID
),
ALLCROSSFILTERED ( Projects )
)
What would I take away from this?
@OwenAuger , thanks for your thorough comments.
I fully agree with your takeaway points.
Regarding this one:
- Microsoft's documentation is lacking and should be updated (I've just placed some feedback myself).
I incline to submit a ticket to Support.
The issue could be resolved either by updating the documentation as you suggested or by fixing the function.
I'd rather they fix it. There is no plausible explanation why this function does not cover all the cases.
I incline to submit a ticket to Support.
I'd like to share the news I got from MS support team:
LOOKUPVALUE was created in the early days of DAX before bi-directional crossfiltering was invented. The function was implemented to ignore filters from tables related to the table of the lookup column but does not ignore filters from bi-directional crossfiltering which didn’t exist back then. The function was not updated to also ignore filters across bi-directional crossfiltering when the latter was invented. In this case, the presence of a filter on the Programs[Program Name] column affected the results of the function. Since this behavior has existed for years, there is a high probability of “breaking” many existing reports by returning different values if we were to update the implementation of the function.
Hence they have considered changing the document and as well they will check that this falls under BUG.
So I was assured that the documentation on LOOKUPVALUE function will be updated to shed light on its hidden details.
ALL(column) is equivalent to REMOVEFILTERS(column).
You should try to use TREATAS for filter context transfers rather than LOOKUPVALUE. (As usual, you need to measure the actual performance/query plan when making a design decision).
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
123 | |
85 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
157 | |
97 | |
79 | |
69 |