Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hi community,
I am having difficulty trying to create a COUNTROWS measure that has both ALL & FILTER. This is my data structure,
Activity | New/Continuation | Role |
A | New | Teacher |
A | New | Teacher |
B | New | Student |
B | Continuation | Student |
C | New | Student |
I would like to COUNT only "New" rows, and also ignore the Roles when putting it in a Matrix that has Roles in Columns. Something like this,
Activity | Teacher | Student |
A | 2 | 0 |
B | 0 | 1 |
C | 0 | 1 |
This is my current measure, but it does not ignore Roles when I place it in my matrix:
Solved! Go to Solution.
Your problem stems from the fact that you do something you should never do: putting a whole table as a filter in CALCULATE. Do not ever do it if you want to create correct formulas and stay sane. The golden rule of DAX is this: You must never filter a table if you can filter a column.
[Measure] =
CALCULATE(
COUNTROWS( Activity ),
KEEPFILTERS( Activity[New/Continuation] = "New" ),
ALL( Activity[Role] )
)
Your problem stems from the fact that you do something you should never do: putting a whole table as a filter in CALCULATE. Do not ever do it if you want to create correct formulas and stay sane. The golden rule of DAX is this: You must never filter a table if you can filter a column.
[Measure] =
CALCULATE(
COUNTROWS( Activity ),
KEEPFILTERS( Activity[New/Continuation] = "New" ),
ALL( Activity[Role] )
)
Hi @Anonymous
Thanks for pointing out my mistake Also really appreciate you explaining the approach I should take to avoid similar mistakes in the future!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
85 | |
70 | |
68 | |
50 | |
32 |
User | Count |
---|---|
117 | |
100 | |
73 | |
65 | |
40 |