cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DimitriD
Helper I
Helper I

Count distinct value with several choices

Helle Dear Community, 

How are you doing?
I have a question.
I made a conditional column that, based on criteria, gives me the sensitive and non-sensitive products.
But, as you will see in the example file, some products can be sensitive and non-sensitive.
When I make the distinction (see pie chart and matrix), I have the total number of rows for the sensitive products and a number for the non-sensitive.
Now what I would like if it is sensitive, it should not be counted as non-sensitive.

 

I also made a measure (category77) that allows me to say that if the value contains characters then it is in a group. It works fine (I think lol) but when I click on the filter I see that the category other has the number of lines.
Dimension filter (GBL_Management_Center and you will see that it does not work.
I don't know where I am making the mistake.
Can you help me?
The file is attached.
Thanks

ExamplepbI 

 

 

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

Hi, @DimitriD ;

You could create a measure.

sensitiv = CALCULATE( DISTINCTCOUNT('Table'[Name]),'Table'[Type]="Sensitive")

and 

Non sen = 
var _a=SUMMARIZE(FILTER('Table',[Type]="Sensitive"),[Name])
var  _b=SUMMARIZE(FILTER('Table',[Type]="Non Sensitive"),[Name])
return COUNTX(EXCEPT(_b,_a),[Name])

The final output is shown below:

vyalanwumsft_0-1638768417610.png

Best Regards,
Community Support Team_ Yalan Wu
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

9 REPLIES 9
v-yalanwu-msft
Community Support
Community Support

Hi, @DimitriD ;

You could create a measure.

sensitiv = CALCULATE( DISTINCTCOUNT('Table'[Name]),'Table'[Type]="Sensitive")

and 

Non sen = 
var _a=SUMMARIZE(FILTER('Table',[Type]="Sensitive"),[Name])
var  _b=SUMMARIZE(FILTER('Table',[Type]="Non Sensitive"),[Name])
return COUNTX(EXCEPT(_b,_a),[Name])

The final output is shown below:

vyalanwumsft_0-1638768417610.png

Best Regards,
Community Support Team_ Yalan Wu
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

Ashish_Mathur
Super User
Super User

Hi,

Your data is such that all Product ID's are definitely non sensitive (some of them are also sensitive).  Since this is how your actual data is are you expecting the answer to be 2,589 sensitive ID's and 216 non sensitive ID's?  This way the total ID's will be 2,805.

Please confirm.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hello @Ashish_Mathur , 

 

Thank you for your reply. 

If I make a measure to obtain the distinct count :

DimitriD_0-1638430319368.png

Sensitive = CALCULATE(DISTINCTCOUNT('Product'[Product_ID]),'Product'[Dimension]="ROLE" && 'Product'[Element]="PNL")
NonSensitive = Distinctcount('Product'[Product_ID])-[Sensitive]
 
Thnak you in advance

 

Hi,

So then you have solved your question.  Am i correct?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur 

 

Hello, Its a workaround. I already test this solution and in future steps I need a measure that counts the number of A and B values. If a user has both A and B values. It will be counted in A and not in B

And I put also a second question in the topic. 

 

Thank you for your help.

 

Hi,

Please leave aside question 2 for now - let us just focus on answering question 1.  Do you need my help for writing a measure which counts product ID's which are both sensitive and non-sensitive?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

hello @Ashish_Mathur 

Thank you for your reply. 

@v-yalanwu-msft give the answer to my first question. 

 

Do you have any idea about the second ?

Hi, @DimitriD ;

Your second problem is “I need a measure that counts the number of A and B values. If a user has both A and B values. It will be counted in A and not in B"?

If this is the second problem, my solution is a simple file for the second problem, or can you share what you want to output?

 

Best Regards,
Community Support Team_ Yalan Wu

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

@v-yalanwu-msft 

Here is the second question. 

I also made a measure (category77) that allows me to say that if the value contains characters then it is in a group. It works fine (I think lol) but when I click on the filter I see that the category other has the number of lines.
Dimension filter (GBL_Management_Center and you will see that it does not work.
I don't know where I am making the mistake

Thank you for your help. 

 

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors