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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
MSAYED26
Helper II
Helper II

distinct count

Hello ,

I want to count how many parts with supplier more than 2 and supplier equal 1

Part Supplier
W0030508752RA
W0030508752RB
W0030509095H-V1A
W0030509095H-V1A
W0030509095H-V1B
W41013044C
W41013621C
W41017168C
W41017173C
W41018408C
W41018445C
2 ACCEPTED SOLUTIONS
freginier
Solution Specialist
Solution Specialist

To count how many parts have a supplier more than 2 and a supplier equal to 1, you can use the following DAX formula:

Count = COUNTROWS(FILTER(Table, Table[Supplier] = "1" || CALCULATE(COUNT(Table[Supplier]), ALLEXCEPT(Table, Table[Part])) > 2))

 

Replace "Table" with the name of your table.

This formula uses the FILTER function to create a filter context where the supplier is equal to "1" or where the count of suppliers for the same part is greater than 2. The COUNTROWS function then counts the number of rows that satisfy the filter context.

Note that the ALLEXCEPT function removes all filters from the table except for the ones specified in the ALLEXCEPT arguments. In this case, we are keeping the filters on the "Part" column to ensure that we are counting suppliers for each unique part.

View solution in original post

v-zhangti
Community Support
Community Support

Hi, @MSAYED26 

 

You can try the following methods.
Measure:

Count Supplier = CALCULATE(DISTINCTCOUNT('Table'[Supplier]),ALLEXCEPT('Table','Table'[Part]))
More than 2 = CALCULATE(DISTINCTCOUNT('Table'[Part]),FILTER(ALL('Table'),[Count Supplier]>=2))
Equal 1 = CALCULATE(DISTINCTCOUNT('Table'[Part]),FILTER(ALL('Table'),[Count Supplier]=1))

vzhangti_0-1678759094493.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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
v-zhangti
Community Support
Community Support

Hi, @MSAYED26 

 

You can try the following methods.
Measure:

Count Supplier = CALCULATE(DISTINCTCOUNT('Table'[Supplier]),ALLEXCEPT('Table','Table'[Part]))
More than 2 = CALCULATE(DISTINCTCOUNT('Table'[Part]),FILTER(ALL('Table'),[Count Supplier]>=2))
Equal 1 = CALCULATE(DISTINCTCOUNT('Table'[Part]),FILTER(ALL('Table'),[Count Supplier]=1))

vzhangti_0-1678759094493.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

Hello V-zhangti,

I working on a similar subject. so I want to ask my question depend this issue:

How can I create a new column for the values "Count Suplier" formula.   Other mean, I need this value as a column not in a measure.  Because I can't use this measure in axis of a chart 😞 

 

Best Regards

MSAYED26
Helper II
Helper II

thanks for your efforts
I want to count without repeating the same parts
the example above count of parts more than 1 supplier =2 parts count of parts equal 1 supplier =6 Parts

Hi,

To your visual, drag Part and this measure.  Filter the measure on > 0

More than 2 suppliers = 1*(DISTINCTCOUNT(Data[Supplier])>=2)

Hope this helps.

Untitled.png


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

MSAYED26_0-1692882548943.png

I have done that but the value is fixed with date . How can I make it change from date ?

You are replying to a March post now in August.  I obviously do not have any context at all.


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

To count how many parts have a supplier more than 2 and a supplier equal to 1, you can use the following DAX formula:

Count = COUNTROWS(FILTER(Table, Table[Supplier] = "1" || CALCULATE(COUNT(Table[Supplier]), ALLEXCEPT(Table, Table[Part])) > 2))

 

Replace "Table" with the name of your table.

This formula uses the FILTER function to create a filter context where the supplier is equal to "1" or where the count of suppliers for the same part is greater than 2. The COUNTROWS function then counts the number of rows that satisfy the filter context.

Note that the ALLEXCEPT function removes all filters from the table except for the ones specified in the ALLEXCEPT arguments. In this case, we are keeping the filters on the "Part" column to ensure that we are counting suppliers for each unique part.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.