Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi folks, I'm trying to create a measure that will respond to filters to give me the number of rows in each group (defined by the value of two columns). Example:
| ID | Classification | Days | Count |
| ID1 | Historical | 7 | 2 |
| ID1 | Historical | 14 | 2 |
| ID1 | Historical | 21 | 1 |
| ID2 | Historical | 7 | 2 |
| ID2 | Historical | 14 | 2 |
| ID3 | Current | 7 | 3 |
| ID3 | Current | 14 | 1 |
| ID3 | Current | 21 | 1 |
| ID4 | Current | 7 | 3 |
| ID5 | Current | 7 | 3 |
I'm currently using the expression Count = CALCULATE(COUNT([ID]), ALLEXCEPT(TableName, [Classification], [Days])) but this isn't responsive to filters. So, for instance, if I filter by another column and wind up with the following data, the Count column doesn't change:
| ID | Classification | Days | Count (with current formula - same as above) | VALUE I NEED |
| ID1 | Historical | 7 | 2 | 1 |
| ID1 | Historical | 14 | 2 | 1 |
| ID1 | Historical | 21 | 1 | 1 |
| ID4 | Current | 7 | 3 | 1 |
Does anyone have suggestions for how to get the column values I need?
Solved! Go to Solution.
Hi @Anonymous
try a measure
Count = CALCULATE(COUNTROWS(TableName),
FILTER(ALLSELECTED(TableName),
TableName[Classification]=SELECTEDVALUE(TableName[Classification]) && TableName[Days]=SELECTEDVALUE(TableName[Days])))
Hi @Anonymous
try a measure
Count = CALCULATE(COUNTROWS(TableName),
FILTER(ALLSELECTED(TableName),
TableName[Classification]=SELECTEDVALUE(TableName[Classification]) && TableName[Days]=SELECTEDVALUE(TableName[Days])))
@Anonymous
Replace COUNT with DISTINCTCOUNT
If it helps, mark it as a solution
Kudos are nice too
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 4 | |
| 4 | |
| 3 |
| User | Count |
|---|---|
| 14 | |
| 12 | |
| 9 | |
| 8 | |
| 7 |