Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Count when the row has value

I have a table like this. 

 

PersonM1M2M3M4
Peter1000
Jane0000
Tom1010
Mary1110

 

I want to count rows when at least one of the M1, M2, M3, and M4 has value.

  • Anonymous's avatar
    Anonymous
    5 years ago

    You can create a measure as follows:

     

    PeopleCount = CALCULATE(

        DISTINCTCOUNT(TableName[Person]), 

        FILTER(ALL(TableName), TableName[M1] + TableName[M2] + TableName[M3] + TableName[M4] >= 1)

    )

     

    BTW, I recently developed this Power BI Smartable android app

    I appreciate it if you can try it and share any feedback.

     

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    You can create a measure as follows:

     

    PeopleCount = CALCULATE(

        DISTINCTCOUNT(TableName[Person]), 

        FILTER(ALL(TableName), TableName[M1] + TableName[M2] + TableName[M3] + TableName[M4] >= 1)

    )

     

    BTW, I recently developed this Power BI Smartable android app

    I appreciate it if you can try it and share any feedback.

     

  • Anonymous , Try a measure

    row count =countrows(filter(Table, Table[M1] +Table[M2]+Table[M3]+Table[M4] >0))

  • Anonymous's avatar
    Anonymous
    Not applicable
    Anonymous

    In your table ALL rows do have a value in ALL columns...