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
keyahorm
Regular Visitor

Removing Duplicated to create a relationship!!!

I am trying to create a relationship between 2 tables. and for all my might and anger I cannot get Powerbi to date the dataset, which I already removed duplicates for in Excel pre load to filter out the duplicates. Always xxx rows xxx -2 unqiue values!

In the query editor I have removed duplicates, removed blank rows, removed errors, Filtered> removed empty. NOTHING, very frustrating.

14 REPLIES 14
KHorseman
Community Champion
Community Champion

If you're trying to create a relationship between two tables, the matching columns that you're relating has to have unique values in at least one of the two tables. You haven't given any specifics about the tables you're trying to relate, so it's hard to give any advice beyond that.





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

Proud to be a Super User!




I have a table that has names and job titles, some names have the same job titles.

I than have another table which is the job titles and salaries, with no duplicate job titles. Therefore this list should be the unique one. Once I load into Powerbi, it says there are 39 rows 37 distinct value. Applying all the things in the original post does not make this list a unique set. What am I doing wrong... 

kcantor
Community Champion
Community Champion

You must have a 'close' match. I would recommend (with such a small dataset) that you simply use the drop down arror for the column and scroll down it to see if you have any matches without capitol letters or spaces. I know you shouldn't have to and I know it is tedious but the last time this happened to me, it was picking up a couple of blank rows and another time, the words matched but the case did not.





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

Proud to be a Super User!




I simplified the numbers for explanation sake. I have 7,904 rows and 7,902 distinct 😞

Go to your query and select that job title column. Go to the Transform Tab and hit the Format menu (middle of the ribbon, near Split Column), and select Capitalize Each Word. Then remove duplicates. If @kcantor is right that will probably catch them. You may also have to pick Trim from the same menu if the problem is an extra space character.





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

Proud to be a Super User!




Side question: holy moly, does everybody in this company have their own unique job title?





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

Proud to be a Super User!




Hahaha seems so ! Thanks for the help thus far both. 

 

Transform trick did not work... 😞

 

I can't understand how following these steps I don't get a unique list:

 

1. Duplicate original table in PowerBI query editor. 

2. Delete all but job titles columns

3. Apply every kind of removed duplicates, removed blank rows, removed errors, Filtered> removed empty.

 

What else can I do?

You did both Capitalize and Trim? OK, we're going to have to hunt this down by hand. Load your query and go into the report editor. Write a measure (with whatever names you called things, obviously):

 

Duplicate Hunter = COUNTA(SalaryTable[JobTitle])

 

Now add a table visual with SalaryTable[JobTitle] and the measure [Duplicate Hunter]. That should give you something that looks like:

 

Job Title                                    Duplicate Hunter

Underwater Basket Weaver       1

Executive Assistant Barista        1

Sarcasm Translator                   1

...

 

Somewhere in that list there's either a pair of titles with a 2, or one title with a 3. Go to filters and set it to Duplicate Hunter is greater than 1. Whatever is left are the duplicates. Hopefully seeing what it is will give you a clue as to how to fix it. If not...uh...we can talk about that when it happens.

 

 

 





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

Proud to be a Super User!




@KHorseman That is a great idea . . . going to hijack this particular reply and ask if you can help me solve my many to many issue: http://community.powerbi.com/t5/Desktop/Is-this-Possible-DAX-many-to-many/m-p/37128#U37128

 





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

Proud to be a Super User!




@kcantor after an hour of thinking about your question I started to smell burning circuitry so I'm going to give my brain a break. But if you could send me your sample data maybe I can do better with something concrete.

 

@keyahorm I'm dying of suspense. What's the word? Did that help you track down the culprit?





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

Proud to be a Super User!




This seems to be a common problem for me, I wonder Microsoft choose not to display the non duplicates?

 

The error "One of the columns must have unique value" is particularly frustrating, especially after you have chosen 'Remove Duplicates' on both columns. I understand there may be technical reasons for this - but from a usage point of view. The error is useless - the computer may as well just beep loudly, would give you same information as the error!

If this is still open, I have found removing duplicates in a workskheet in the source file (usually excel) is easier. Then you can load the table to creat the relationship in Power BI.

Nice, I didn't even think of "Job Title" vs "Job title". That's probably more likely than my guess.





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

Proud to be a Super User!




Sort the job titles in alphabetic order and look for whatever it's showing as duplicates. If there are only 37 unique values you definitely have duplicates even if you don't expect them. How many actual job titles are in the source file? If it's 39 then you must have duplicates in the source file without realizing it. if it's only 37 then somehow you have duplicated a couple of rows in your query, in which case I'd say let's see your query code from the advanced editor (sanitized as necessary for security purposes of course).

 

My guess is that you have something like the same job title in two different departments with two different salaries. Removing duplicate rows from the table would leave those because the combination of Job Title X and Salary Y is different from Job Title X and Salary Z.





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

Proud to be a Super User!




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.