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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rinaemo
Frequent Visitor

DISTINCT Count with Condition

Hi everyone, I have this table on PowerBI with 3 columns:

1. Month

2. Centres

3. Employee No

 

I need to do a distinct count on Employee No based on the month and centres but I am unable to do so 😞 can anyone advise ?

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

Hi  @rinaemo ,

 

Based on your error message, my guess is that you copied and pasted the table creation DAX function from @FreemanZ  second reply into the new measure, and based on your latest requirements, I think you can achieve this by trying the new measure in @FreemanZ  third reply.

EmployeeCount = DISTINCTCOUNT(TableName[Employee No])

 

Best Regards,

Liu Yang

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

5 REPLIES 5
v-yangliu-msft
Community Support
Community Support

Hi  @rinaemo ,

 

Based on your error message, my guess is that you copied and pasted the table creation DAX function from @FreemanZ  second reply into the new measure, and based on your latest requirements, I think you can achieve this by trying the new measure in @FreemanZ  third reply.

EmployeeCount = DISTINCTCOUNT(TableName[Employee No])

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

FreemanZ
Super User
Super User

there are multiple ways and you can create a table with the code below
SumTable=
ADDCOLUMNS(
    SUMMARIZE(
        TableName,
        TableName[Month],
        TableName[Centre]
     ),
   "EmployeeCount",
    CALCULATE(
  DISTINCTCOUNT(TableName[Emoloyee No])
    )
)

I've gotten this error message for this.. 😞

 

The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

you can also create a measure with this code
EmployeeCount := DISTINCTCOUNT(TableName[Employee No])
the plot a visual table with the Month, Centres and the measure.

It does count the distinct employees, but when i plot in the centres it shows duplicate.

 

Because there's this specific month that this employee appeared twice in 2 different centre. So i am trying to get the unique value to eliminate the extra employee entry in another centre. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.