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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors