cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
wwcnd Member
Member

how to count distinct values in a column

HI I have a column with 2 different text values in, and i need to create a measure that can make a distinct count of these 2 values I have see the following https://community.powerbi.com/t5/Desktop/CALCULATE-count-of-several-text-values/m-p/33878/highlight/... But this is counting all the rows. I have tried to change it a bit, but no success
1 ACCEPTED SOLUTION

Accepted Solutions
wwcnd Member
Member

Re: how to count distinct values in a column

solved with the following

 

CountItem = CALCULATE (
    DISTINCTCOUNT (TblName[itemnumber] );TblName[Status]="Open")

 

5 REPLIES 5
Framet Regular Visitor
Regular Visitor

Re: how to count distinct values in a column

Hi,

 

Without seeing some example data this isn't all that clear. If you have two possible text values in a column then distinct count will only return 0,1,2 depending on your filters. Is this your desired result?

It might seem a bit obvious but does DISTINCTCOUNT([Your Column Name] return what you need?

Thanks

Thomas

wwcnd Member
Member

Re: how to count distinct values in a column

solved with the following

 

CountItem = CALCULATE (
    DISTINCTCOUNT (TblName[itemnumber] );TblName[Status]="Open")

 

Re: how to count distinct values in a column

This work with me In measure (correct value) but On column, it gives a wrong value , why ?

sphillips22 Frequent Visitor
Frequent Visitor

Re: how to count distinct values in a column

Worked perfectly! Thank you so much!

gusdahu Member
Member

Re: how to count distinct values in a column

Hi @wwcnd ,

 

I used the same DAX you posted, however I received a result of one when it should've been two. What am I doing incorrectly? Here is my DAX expression:

 

Count Words = CALCULATE(DISTINCTCOUNT(Sheet1[Description]),Sheet1[Description]="Gloves")
 
Regards,
Gus Dahu