Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

DISTINCTCOUNT with filter condition doesn't work

Hello all, 

 

I am sort of new to Power BI. I just took a Microsoft Power BI online class. I am tryining to do a simple calculated measure. I want to count all distinct employeeids who's CompanyCategory is "Tradesman". If I run a query in SQL Server or when I look in my data in the Data tab I see the Tradesman values in the table. Seems simple. So I have a DAX formula like this: 

TotalTradesmenCount = CALCULATE( DISTINCTCOUNT(ManpowerRpt[EmployeeID]), FILTER( ManpowerRpt, ManpowerRpt[CompanyCategory] = "Tradesman"))
I also tried this:
TotalTradesmenCount = CALCULATE( DISTINCTCOUNT(ManpowerRpt[EmployeeID]), ManpowerRpt[CompanyCategory] = "Tradesman")
 
When I place a Card on my report and put the calculated measure where I see "(Blank)TotalTradesmenCount". 
What do I do wrong?
Thank you!
Stan
  • calerof's avatar
    calerof
    7 years ago

    Hi Anonymous ,

     

    You have a typo in your measure my friend!

     

    You wrote "Tradesman", it should be "Tradesmen".

     

    Cheers,

     

    Fernando

     

5 Replies

  • calerof's avatar
    calerof
    Icon for Impactful Individual rankImpactful Individual

    Hi Anonymous ,

     

    Why don't you share your pbix file to understand your data?

    Regards,

    Fernando

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Unfortunately, I can't share the file since it has sensitive information. What I can do it to post a snapshot of my table where you can see one row with the CompanyCategory = "Tradesmen":

       

       

      I expect to see a numbe 1 in the Card becasue for a distinct count of the empoyees there is only one row that matches the filtering condition.

      • calerof's avatar
        calerof
        Icon for Impactful Individual rankImpactful Individual

        Hi Anonymous ,

         

        You have a typo in your measure my friend!

         

        You wrote "Tradesman", it should be "Tradesmen".

         

        Cheers,

         

        Fernando