Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have table :
Sales
ProductCat ProductGroup Sales
1 1 100
2 1 105
3 2 34
4 2 23
5 5 1000
I need to filter out Product Cat 5 and then add a rank column, partitioned by ProductGroup i.e. :
ProductCat ProductGroup Sales Rank
1 1 100 2
2 1 105 1
3 2 34 1
4 2 23 2
I can do the rank with :
ADDCOLUMNS('Sales', "Rank", RANKX(CALCULATETABLE('Sales', ALLEXCEPT('Sales', 'Sales[ProductGroup]), 'Sales'[Sales])
One thing I'm struggling with filtering out ProductCat 5 before running the RANKX. I tried adding it into CALCULATETABLE as an additional filter but this has no effect due to the ALLEXCEPT. I've tried a nested CALCULATETABLE with the filter but this has no effect either.
Any ideas how I can apply a filter prior to CALCULATETABLE?
Solved! Go to Solution.
Easy answer is to try this:
One thing you can do is use a MEASURE instead. That will enable you to create a table visualization that can have the measure added to it. Then you can filter that visual to exclude category 5 and the rankings will update.
Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos.
I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query.
https://sites.google.com/site/allisonkennedycv
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Easy answer is to try this:
One thing you can do is use a MEASURE instead. That will enable you to create a table visualization that can have the measure added to it. Then you can filter that visual to exclude category 5 and the rankings will update.
Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos.
I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query.
https://sites.google.com/site/allisonkennedycv
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Just to clarify. Are you trying to make a measure? calculated column? or calculated table? Depending on what your goal, I would suggest a simpler DAX expression to achieve your goal.
FYI that you can just add a term to your Calculatetable( ) expression to filter out ProductCat <> 5 after the Allexcept() clause. Note there seems to be a missing parentheses after that anyway.
Regards,
Pat
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
I'm sticking with table at the moment as there's more processing to do. We can't add filters in CALCULATE as filter context is being amended by allselected().
I will try applying the filter in an outer calculate.
This article explains it all
https://www.sqlbi.com/articles/order-of-evaluation-in-calculate-parameters/
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
15 | |
9 | |
7 | |
7 | |
6 |
User | Count |
---|---|
22 | |
11 | |
10 | |
10 | |
8 |