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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
DANNYBLACK
New Member

COUNTROWS - Not counting as expected.

Hi

I am pulling my hair out with this... (FYI new to PowerBI)

I am trying to count the number of rows that have a value where RED - I am expecting the measure to return 6 but it is doing a SUM rather than counting and returning 19!

Screenshot 2022-03-15 at 13.27.46.png

 

 

NUMBER OF RED = COUNTROWS(FILTER('Page 1','Page 1'[RED]>0))

 

 

 

FYI RED is a measure in itself

 

 

RED = 
CALCULATE(
COUNTROWS('Page 1'),'Page 1'[Residual Score] = "RED",
ALLSELECTED('Page 1'[Entity])
) + 0

 

 

 

Any help would be greatly apprecaited. 🙂

Thanks - Danny

1 ACCEPTED SOLUTION
v-kkf-msft
Community Support
Community Support

Hi @DANNYBLACK ,

 

Please try the following formula:

 

Measure = 
COUNTX ( FILTER ( VALUES ( 'Page 1'[Subcategory] ), [RED] > 0 ), [RED] )

vkkfmsft_0-1647581502959.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

7 REPLIES 7
v-kkf-msft
Community Support
Community Support

Hi @DANNYBLACK ,

 

Please try the following formula:

 

Measure = 
COUNTX ( FILTER ( VALUES ( 'Page 1'[Subcategory] ), [RED] > 0 ), [RED] )

vkkfmsft_0-1647581502959.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

truptis
Community Champion
Community Champion

@DANNYBLACK -> Since RED is a measure, it is giving us the error. Because COUNT supports a column. eg- COUNT([columnname]).
If you could tell what exactly you are expecting in RED measure, we can make RED as a column and figure out

truptis
Community Champion
Community Champion

@DANNYBLACK -> How are you deriving [RED]? what formula are you using?

Hi @truptis 

RED is a MEASURE

RED = 
CALCULATE(
COUNTROWS('Page 1'),'Page 1'[Residual Score] = "RED",
ALLSELECTED('Page 1'[Entity])
) + 0

I just need to count the number of rows where RED has a value > 0

DANNYBLACK
New Member

@amitchandak 

NUMBER OF RED = SUMX(VALUES('Page 1'[Subcategory]), 'Page 1'[RED])

This still returns a value of 19 (expectation is 6)

 

@truptis 

Screenshot 2022-03-15 at 14.43.35.png

 

So sorry, unless I have complely misunderstood neither of thoes worked. 

 

Any other ideas?

 

 

amitchandak
Super User
Super User

@DANNYBLACK , if Red is a measure then try like

Sumx(values(table[Sub Category]), [RED])

truptis
Community Champion
Community Champion

Hi @DANNYBLACK ,
Try using this -

Result = Calculate(count([Red]), filter(tablename, tablename[Red] <> 0)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.