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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
admin_xlsior
Post Prodigy
Post Prodigy

JOIN 2 tables with DISTINCT(UNION)) result many 2 many relationship

Hi,

 

Recently I was joining 2 tables, so that I can get the unique value of this tables.

 

So I create this query :

 

Unique Location = DISTINCT(
    UNION(
        DISTINCT('Table A'[Location]),
        DISTINCT(Table B[Location])       
    )
)
 
FYI, the column [Location] is just a location code with many duplicates since it is a transaction table. And the reason I want to create a new unique table because I want to put a relationship between this two but cannot since it will create Many to Many relationship.
 
So in that query, logically, it would create a new table with unique value of "Location", right ?
So does what it looks like in the table result.
 
But strange is when I want to connect this new table "Unique Location" to Table A or Table B, it still tell me it is Many 2 Many.
What is wrong with that query ?
 
Thanks,
 
 
 
 
 
 
 
 
 
1 ACCEPTED SOLUTION

@admin_xlsior hmm seems like there is a blank row and wondering if that is the root cause.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

6 REPLIES 6
parry2k
Super User
Super User

@admin_xlsior can you check what output you are getting Unique Location table. I just tested at my end and it worked as expected.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Yes, 

it does have unique value :

 

Location

 
010
109
110
111
112
113
114
115
116

@admin_xlsior hmm seems like there is a blank row and wondering if that is the root cause.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

 Actually I expect that, but if it is the blank causing it, I can remove it.

 

However been trying this query :

 

DISTINCT(
    UNION(
        DISTINCT(ALLNOBLANKROW('Table A'[Location])),
DISTINCT(ALLNOBLANKROW('Table B'[Location]))
    )

 

but cannot get rid of the blank row.

 

Also tried the FILTER like this :

 

DISTINCT(
UNION(
        DISTINCT(FILTER(VALUES('Table A'[Location]), LEN('Table A'[Location])>0)),
        DISTINCT(ALLNOBLANKROW('Table B'[Location]))   
    )

 

the first table filter (Table A) already gave an error saying "a circular dependency was detected", but  I think this is because the way I get this data.

 

Anyway, I thought DISTINCT will ignore Blank ? VALUES include Blank, right ?

 

Thanks,

 

You are right it does because of the blank row. And I need to remove it by this query :

 
DISTINCT(FILTER(VALUES('Table A'[Location]), 'Table A'[Location] <> "") ),

 

Strange, with the same logic, only I'm using Len(Table A[Location] > 0), it does not work. 

 

Many thanks for your help,

 

@admin_xlsior sorry I was away, seems like you have solution in place. Glad to help!!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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