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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Justin_Spiegel
Frequent Visitor

Calculate Distinct Key with Multiple Duplicate Line Items

I am trying to calcuate for distinct values where a customer order returns multiple delivery orders, while excluding the packaging IDs.

 

TABLE 1

Customer Order #Delivery OrderPackaging IDKey
123455566A1123455566
123455566A2123455566
123455565A1123455565
123455566A3123455566
123455566A4123455566

 

In this example above, I want it to report that Customer Order has 2 Distinct Values but I am struggling with that CALCULATE function. Doing it as a Calculated Column causes elevated row values that are hard to isolate (i.e. Key ID 123455566 would return 4 for each line item)

 

The Calculate I have tried are not working yet:

=CALCULATE(DISTINCTCOUNT('Table 1'[Key]))

 

and 

var CustomerOrder = 'Table 1'[Key]

return

CALCULATE(COUNT('Table 1'[Customer Order #]), 

ALL('Table 1'), 'Table 1'[Key] = CustomerOrder

1 REPLY 1
MFelix
Super User
Super User

Hi @Justin_Spiegel ,

 

Why are you using a calculated column the type of calculation you describe would be calculated more efectively on a measure. Making a calculated column you will have the table context that will need additional context.

 

So depending on where you use the measure you can have the result you need in this case simply use the measure:

 

Count order =DISTINCTCOUNT('Table 1'[Key])


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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