Forum Discussion

gambleave's avatar
gambleave
Helper II
3 years ago
Solved

Countrows based on distinct field

Hi, I have the below measure to count the number of records in the table "Employee Vote" where 

the Role is indicated as Sales and the Region is Europe. 

 

Count Europe Sales Votes = 

CALCULATE(COUNTROWS('Employee Vote'), FILTER(FILTER('Employee Vote', Employee Vote[Role]="Sales"), 'Employee Vote'[Region]="Europe"))

 

Additionally, I would like to count only distinct records by an "Employee Name" column in the same table. How can I modify the syntax to achieve this? Thank you. 

 

  • Hi,

    Please try the below whether it suits your requirement.

     

     

    Count Europe Sales Name =
    CALCULATE (
        COUNTROWS ( DISTINCT ( 'Employee Vote'[Employee Name] ) ),
        FILTER (
            'Employee Vote',
            'Employee Vote'[Role] = "Sales"
                && 'Employee Vote'[Region] = "Europe"
        )
    )
    

     

2 Replies

  • Hi,

    Please try the below whether it suits your requirement.

     

     

    Count Europe Sales Name =
    CALCULATE (
        COUNTROWS ( DISTINCT ( 'Employee Vote'[Employee Name] ) ),
        FILTER (
            'Employee Vote',
            'Employee Vote'[Role] = "Sales"
                && 'Employee Vote'[Region] = "Europe"
        )
    )