Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin 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.
Hi PowerBI experts! How do you distinct count a field based on a criteria on another columns' aggregation?
example:
| StaffID | Score |
| 101 | 56 |
| 101 | 43 |
| 102 | 12 |
| 101 | 15 |
| 103 | 43 |
| 104 | 31 |
| 104 | 25 |
| 102 | 19 |
| 101 | 23 |
| 101 | 16 |
Desired output:
Distinct Count of StaffID where Average of Score is greater than or equal to 20.
Thanks in advance
Solved! Go to Solution.
@Anonymous,
Try this measure. The VALUES function returns distinct StaffID, enabling COUNTROWS to return distinct count.
Distinct Count StaffID =
VAR vTable =
ADDCOLUMNS (
VALUES ( Table1[StaffID] ),
"@Average", CALCULATE ( AVERAGE ( Table1[Score] ) )
)
VAR vResult =
COUNTROWS ( FILTER ( vTable, [@Average] >= 20 ) )
RETURN
vResult
Proud to be a Super User!
hi @Anonymous
you can also create a measure with this:
Avg20PlusCount =
VAR _table =
ADDCOLUMNS(
VALUES(TableName[StaffID]),
"ScoreAvg",
CALCULATE(AVERAGE(TableName[Score]))
)
RETURN
COUNTROWS(
FILTER(
_table,
[ScoreAvg]>=20
)
)
it worked like this:
@Anonymous,
Try this measure. The VALUES function returns distinct StaffID, enabling COUNTROWS to return distinct count.
Distinct Count StaffID =
VAR vTable =
ADDCOLUMNS (
VALUES ( Table1[StaffID] ),
"@Average", CALCULATE ( AVERAGE ( Table1[Score] ) )
)
VAR vResult =
COUNTROWS ( FILTER ( vTable, [@Average] >= 20 ) )
RETURN
vResult
Proud to be a Super User!
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.