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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Sum Distinct Count

Hi Folks,

 

I created dax to distinct count each material that appear for each market.

 

Table Name: OrderIntake

Distinct_Count_Material = DISTINCTCOUNT(OrderIntake[Material])

 

MaterialIndonesiaMalaysiaMongoliaPhilippinesVietnam
6325040100111111
6325140100110111
6325140101411110
6325140117801111
6325140137501110

 

Question, how do I sum the distinct for each material?

Desired output =

material# 63250401001  = 5

 

And would it be possible to then show it as a percentage over 5 countries?

e.g. 63250401001 = 5/5 = 100%,

63251401001 = 4/5 80%

 

Thanks for the help in advance.

 

Regards

Hidayat

 

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

Hi @Anonymous,

 

1. If your sample data is raw data in Data view, you can follow below steps:

 

(1). Create calculated columns below:
sum = VALUE([Indonesia])+VALUE([Malaysia])+VALUE([Mongolia])+VALUE([Philippines])+VALUE([Vietnam])
Percentage = DIVIDE(OrderIntake[sum],COUNTROWS(OrderIntake))

 

q1.jpg

 

(2).Modify the column[percentage], format it from general to percentage.

q2.jpg

 

(3).Create a Table visual in your report and add the [Material], [Indonesia], [Malaysia], [Mongolia], [Philippines], [Vietnam], [Sum] and [Percentage] fields.

q3.jpg

 

You can also download the PBIX file "Sum Distinct Count1" to have a view.

2. If your sample data is from a matrix visual, you can refer to below steps:
(1).You can create two measures below:
Distinct_Count_Material =
IF(COUNT(Sheet2[Material])=CALCULATE(COUNT(Sheet2[Material]),ALLEXCEPT(Sheet2,'Sheet2'[Material])),CALCULATE(COUNT(Sheet2[Material]),ALLEXCEPT(Sheet2,'Sheet2'[Material])),COUNT(Sheet2[Country]))

Percentage = IF(COUNT(Sheet2[Material])=CALCULATE(COUNT(Sheet2[Material]),ALLEXCEPT(Sheet2,'Sheet2'[Material])),CALCULATE(COUNT(Sheet2[Material]),ALLEXCEPT(Sheet2,'Sheet2'[Material])),BLANK())/CALCULATE(DISTINCTCOUNT(Sheet2[Country]),ALL(Sheet2))

(2).You can create a Matrix visual and add your [Material], [Country], [Distinct_Count_Material] and [Percentage] fields.

q4.jpg

 

You can also download the PBIX file "Sum Distinct Count2" to have a view.

 

Best Regards,
Qiuyun Yu

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

2 REPLIES 2
v-qiuyu-msft
Community Support
Community Support

Hi @Anonymous,

 

1. If your sample data is raw data in Data view, you can follow below steps:

 

(1). Create calculated columns below:
sum = VALUE([Indonesia])+VALUE([Malaysia])+VALUE([Mongolia])+VALUE([Philippines])+VALUE([Vietnam])
Percentage = DIVIDE(OrderIntake[sum],COUNTROWS(OrderIntake))

 

q1.jpg

 

(2).Modify the column[percentage], format it from general to percentage.

q2.jpg

 

(3).Create a Table visual in your report and add the [Material], [Indonesia], [Malaysia], [Mongolia], [Philippines], [Vietnam], [Sum] and [Percentage] fields.

q3.jpg

 

You can also download the PBIX file "Sum Distinct Count1" to have a view.

2. If your sample data is from a matrix visual, you can refer to below steps:
(1).You can create two measures below:
Distinct_Count_Material =
IF(COUNT(Sheet2[Material])=CALCULATE(COUNT(Sheet2[Material]),ALLEXCEPT(Sheet2,'Sheet2'[Material])),CALCULATE(COUNT(Sheet2[Material]),ALLEXCEPT(Sheet2,'Sheet2'[Material])),COUNT(Sheet2[Country]))

Percentage = IF(COUNT(Sheet2[Material])=CALCULATE(COUNT(Sheet2[Material]),ALLEXCEPT(Sheet2,'Sheet2'[Material])),CALCULATE(COUNT(Sheet2[Material]),ALLEXCEPT(Sheet2,'Sheet2'[Material])),BLANK())/CALCULATE(DISTINCTCOUNT(Sheet2[Country]),ALL(Sheet2))

(2).You can create a Matrix visual and add your [Material], [Country], [Distinct_Count_Material] and [Percentage] fields.

q4.jpg

 

You can also download the PBIX file "Sum Distinct Count2" to have a view.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Qiuyun, 

 

Thanks for the feedback. The solution is as Distinct Count 2 file.

 

Using Distinct Count 2.pbix, If I were to add column "group" to sheet 2 table and group countries together , how do I achieved below table output?

 

Group Column Defination

Indonesia & Malaysia = Group A

Mongolia & Philippines = Group B

Vietnam = Group C

 

Desired Output

MaterialGroup AGroup BGroup CTotal 
632504010011113 
632514010011113 
632514010141113 
632514011781102 
632514013751102 

 

Many thanks!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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