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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

7 REPLIES 7
MattAllington
Community Champion
Community Champion

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.
I will not give you bad advice, even if you unknowingly ask for it.

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.
I will not give you bad advice, even if you unknowingly ask for it.

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.
I will not give you bad advice, even if you unknowingly ask for it.

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.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors