Forum Discussion

DANNYBLACK's avatar
DANNYBLACK
New Member
4 years ago
Solved

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!

 

 

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

  • Hi DANNYBLACK ,

     

    Please try the following formula:

     

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

     

    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.

     

7 Replies

  • truptis's avatar
    truptis
    Community Champion

    Hi DANNYBLACK ,
    Try using this -

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

    • DANNYBLACK's avatar
      DANNYBLACK
      New Member

      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

  • amitchandak 

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

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

     

    truptis 

     

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

     

    Any other ideas?

     

     

  • truptis's avatar
    truptis
    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

  • v-kkf-msft's avatar
    v-kkf-msft
    Community Support

    Hi DANNYBLACK ,

     

    Please try the following formula:

     

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

     

    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.