Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I think I am just confused about the context of filter function used in a calculated column:
Say you want to rank the products by price in products table, by creating a calculated column in the products table as below - my question is, why the filter function in red below is not taking the row context of the current row, but having access to the entire products table, and loop row by row?
Price rank =
var currentPrice = products[Price]
return
countrows(
filter(
products, products[Price]>currentPrice))+1
Thanks!
NM
Solved! Go to Solution.
When you reference a table in a calculated column, rather than a single value from the row context, DAX interprets it as the whole table rather than just a single row unless there is a context transition involved that converts the row context into a filter context.
Basically, it treats a table as an unfiltered table unless there is filter context involved and there isn't any inherent filter context in a calculated column unless you create some.
Hi, @NanPowerBI
Just try something like:
Price rank =
VAR currentPrice = products[Price]
RETURN
COUNTX(
FILTER(
products, products[Price]>currentPrice))+1
Did I answer your question? Please Like and Mark my post as a solution if it solves your issue. Thanks.
Appreciate your Kudos !!!
https://www.youtube.com/channel/UCndD_QZVNB_JWYLEmP6KrpA
Proud to be a Super User!
When you reference a table in a calculated column, rather than a single value from the row context, DAX interprets it as the whole table rather than just a single row unless there is a context transition involved that converts the row context into a filter context.
Basically, it treats a table as an unfiltered table unless there is filter context involved and there isn't any inherent filter context in a calculated column unless you create some.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.