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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

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, @Anonymous ;

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, @Anonymous ;

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.

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/
Anonymous
Not applicable

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/
Anonymous
Not applicable

@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/
Anonymous
Not applicable

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, @Anonymous ;

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.

Anonymous
Not applicable

@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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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