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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
FireFireFire
Frequent Visitor

JOIN and UNION in Power BI? Better way than using conditional column?

I have two tables tblcalls and tblcallscc which stand in a 1:1 relationship via tblcalls.call_id and tblcallscc.cc_call_id. I want to merge them to one big table. Howevery, sometimes records are missing in one of the tables. And I also want to have a new column "id" that holds either tblcalls.call_id or tblcallscc.cc_call_id of whatever record exists.

 

Example:

union.PNG

 

This is what I would do in SQL to achieve this:

 

SELECT call_id as "id", * FROM tblcalls LEFT JOIN tblcallscc ON call_id = cc_call_id
UNION
SELECT cc_call_id as "id", * FROM tblcalls RIGHT JOIN tblcallscc ON call_id = cc_call_id  ORDER BY i

 

Now in Power BI I managed to do the UNION via "Merge Queries ->Merge Queries as New" and use a FULL OUTER JOIN. However, I am a bit lost how to efficiently add the "id" column.

 

Edit: I actually just found a way. What I did was to add a Conditional Column, but I would like to know if this is the way to do it, of if there is a better way.

 

add_column.PNG

1 ACCEPTED SOLUTION

then  I don't see any better method other than yours.

View solution in original post

3 REPLIES 3
Sunkari
Responsive Resident
Responsive Resident

Go for full outer join

Refer the below link for more details.

 

http://radacad.com/how-to-change-joining-types-in-power-bi-and-power-query

Sorry, I missed a word in my Question. I did use the FULL OUTER JOIN. My question was, if the way I added the "id" column  could be improved.

then  I don't see any better method other than yours.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.