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
DataUsurper
Helper II
Helper II

Disctint Union won't allow relationship due to non-Unique (Distinct) values?

Hello,

I have the following table formula for a distinct value from three separate tables:

keyMeasures = 
DISTINCT(
UNION(
SELECTCOLUMNS('Availability Top 10K',"keyCombo",'Availability Top 10K'[Combo Code]),
SELECTCOLUMNS('Revenue Top 10K',"keyCombo",'Revenue Top 10K'[Combo Code]),
SELECTCOLUMNS('Utilization Top 10K',"keyCombo",'Utilization Top 10K'[Combo Code])
))

but when I attempt to link a table's value to that new keyCombo field it is telling me there are duplicate values in both fields. I've confirmed (copy/pasting above results to Excel) that that above code does not produce a duplicate value. Any ideas why I'm getting this error?

 

Thank you much

keyCombo.png

keyCombo2.png

1 ACCEPTED SOLUTION

Why do you need a relationship if you’re objective is to create a unique list of keys?  Or are you just using that to validate that this list is unique?  Check it doesn’t have any blanks, as you can’t create a relationship if there is a blank on the primary key. 




* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

7 REPLIES 7

UNION in DAX is the same as UNIONALL in SQL. wrap the whole thing inside a DISTINCT()



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Hi Matt and thanks for the quick reply,

 

The formula begins and is wrapped in a Disctinct() function, at least I believe it is. I thought maybe if I removed the union it might work but nay, the formula wouldn't complete w/out it.

Oh, sorry. The issue is most likely therefore different data in the non-primary key columns. Cna you use Power Query instead?  Select remove duplicates. 



 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

The data contains daily records, so there will be a lot of instances of the same codes.

 

This is my current model layout without any of the relationship errors, leading me to believe it's in the creatd "keyCombo" formula we're working on.?.

keyCombo3.png

What is the purpose of the to-be red relationship?



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Creating a unique list of records (key) from multiple tables' fields so I don't have to create one in Excel

Why do you need a relationship if you’re objective is to create a unique list of keys?  Or are you just using that to validate that this list is unique?  Check it doesn’t have any blanks, as you can’t create a relationship if there is a blank on the primary key. 




* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

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.