cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Alvarom1 Frequent Visitor
Frequent Visitor

Help on DAX-DISTINCTOUNT

Hi

I want to calculate a number of distinctcount for this table

 

LetterColor
aWhite
aRed
bWhite
cWhite
cRed
dRed
eWhite
f 
gWhite
gRed
iRed

 

and i need to calculate the distinct count of letters that have onle "White". In this simple case the result it would be 2 (letters b & e).

Can you help me on using that to make the calculation with DAX?

Many thanks

Alvaro

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Help on DAX-DISTINCTOUNT

hi, @Alvarom1 

You could try this way as below to get it:

Step1:

Create a measure that DISTINCTCOUNT different colors of each letter.

different colors each Letter = CALCULATE(DISTINCTCOUNT('Table'[Color]))

Step2:

Create a measure that DISTINCTCOUNT while colors of each letter.

Only white each letter = CALCULATE(DISTINCTCOUNT('Table'[Letter]),FILTER('Table','Table'[Color]="White"))

Step3:

Then use this measure to get your requirement:

Result = CALCULATE(DISTINCTCOUNT('Table'[Letter]),FILTER(VALUES('Table'[Letter]),[different colors each Letter]=[Only white each letter]))

Result:

7.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
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

7 REPLIES 7
amitchandak Super Contributor
Super Contributor

Re: Help on DAX-DISTINCTOUNT

Try

calculate(DISTINCTCOUNT(letter),color="White")

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

Alvarom1 Frequent Visitor
Frequent Visitor

Re: Help on DAX-DISTINCTOUNT

Thanks for your reply. But with that the result is 5 as it includes the letters that have "White" but also "Red". The result that I am looking for is 2, only letters that have "White" and no other color.

Hope is clear. Any suggestion?

Thanks!

Alvaro

amitchandak Super Contributor
Super Contributor

Re: Help on DAX-DISTINCTOUNT

That should filter white

calculate(DISTINCTCOUNT(letter),color="White")

Other solution

calculate(DISTINCTCOUNT(letter),filter(table,color="White"))
Alvarom1 Frequent Visitor
Frequent Visitor

Re: Help on DAX-DISTINCTOUNT

Thanks again, but with that I do not get the expected result that is the distinct count of letters that have ONLY "White", excluding the letters that have "White" and "Red" , that in this table are letters "b" and "e", that is 2 letters. Your formula gives me 5 as result but what I expect is 2

 

Makes it sense?

 

Thanks again!

 

Alvaro 

 

@amitchandak 

Community Support Team
Community Support Team

Re: Help on DAX-DISTINCTOUNT

hi, @Alvarom1 

You could try this way as below to get it:

Step1:

Create a measure that DISTINCTCOUNT different colors of each letter.

different colors each Letter = CALCULATE(DISTINCTCOUNT('Table'[Color]))

Step2:

Create a measure that DISTINCTCOUNT while colors of each letter.

Only white each letter = CALCULATE(DISTINCTCOUNT('Table'[Letter]),FILTER('Table','Table'[Color]="White"))

Step3:

Then use this measure to get your requirement:

Result = CALCULATE(DISTINCTCOUNT('Table'[Letter]),FILTER(VALUES('Table'[Letter]),[different colors each Letter]=[Only white each letter]))

Result:

7.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
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

Alvarom1 Frequent Visitor
Frequent Visitor

Re: Help on DAX-DISTINCTOUNT

It works!

Thanks a lot

Alvaro

Alvarom1 Frequent Visitor
Frequent Visitor

Re: Help on DAX-DISTINCTOUNT

HI Again,

as I confirmed, it works.

The issue that I have now is that the database is big and when it comes to calculate the last measure it takes a long time (several minutes) until the result appears.

Any idea to make it faster?

Thanks

Alvaro

 

@v-lili6-msft 

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 6 members 4,112 guests
Please welcome our newest community members: