Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
yishenhui
Helper II
Helper II

how to count a measure based on the measure itself

Hi,

 

Below screenshot is from a measure table, "TotalScore", "ScoreRange" are measures. I want to count one of the measures based on the measure. For example, if I count totalscore, I want to return ((99.6%, 2), (99.0%,2), (97.9%,1)...) How can I do that?

image.png

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @yishenhui 

let's assume that this is a student data (this is irrelevant anyway but only to explain)

 

first create the following calculated table

 

Marks =
SELECTCOLUMNS ( GENERATESERIES ( 0.001, 0.001, 1 ), "Mark", [Value] )

 

then use the following measure 

Count =
COUNTROWS (
FILTER (
ADDCOLUMNS (
CROSSJOIN ( VALUES ( 'Table'[Student ID] ), VALUES ( Marks[Mark] ) ),
"@Score", [TotalScore]
),
[Mark] = [@Score]
)
)

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @yishenhui 

let's assume that this is a student data (this is irrelevant anyway but only to explain)

 

first create the following calculated table

 

Marks =
SELECTCOLUMNS ( GENERATESERIES ( 0.001, 0.001, 1 ), "Mark", [Value] )

 

then use the following measure 

Count =
COUNTROWS (
FILTER (
ADDCOLUMNS (
CROSSJOIN ( VALUES ( 'Table'[Student ID] ), VALUES ( Marks[Mark] ) ),
"@Score", [TotalScore]
),
[Mark] = [@Score]
)
)

Hi Tamerj,

 

I understand your DAX but not sure why it's still not working. (I adjusted the Marks table a little

Marks = SELECTCOLUMNS ( GENERATESERIES ( 0.000, 1.001,0.001 ), "Mark", [Value] ) as the max value should be the second place and 0 and 100 is an accept-able value.)   
however, the result gives empty. See below screenshot, the column scorescount supposes give the count number when it's the same as the score. I have created table step by step and found once apply the filter, the table goes to empty. I even added another column with [Mark]-[totalscore], it does show the difference between the two value. However once I apply the filter for that column value 0, the table goes to empty. (I used a table visual to monitor it). The DAX is as
Table 2 = ADDCOLUMNS ( CROSSJOIN ( VALUES ( DataQuery[analystname] ), VALUES ( Marks[Mark] ) ), "@Score", [TotalScore],"mark-score",[Mark]-[TotalScore] )
Any idea where is the issue?
 image.png

)

@yishenhui 

Plaxe the column Mark in a new table visual along with the Count measure 

Hi Tamerj,

I got more progress. The totalscore is a calculated value which usually is not exact match the mark.value. I used another column scorerange which is result of floor. I got some count numbers and found they are not match the manual count result. I found I need to add column "year/month" to the table as well. Finally I got the correct numbers. I will mark your answer as solution as the method you provided is the key to reslove it. Thanks!

image.png

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.