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
Anonymous
Not applicable

How to Join tables and Add column using DAX(Edit Query)

I have to join two tables A and B using ID.
Then add on column 'Degree' from table B to Table A
Expected O/P : Table contains column A,B & C

Input File:

Table A
IDName
111Adex
222belly
333Caty
Table B
IDDegree
111B.Com
222B.Tech
333BCA

 

Expected Ouput :

Table A
IDNameDegree
111AdexB.Com
222bellyB.Tech
333CatyBCA



Using DAX (Edit query/Transform Data)
Please help me out solving this and if possible please explain syntax to be used.


Thanks in Advance!

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Providing you have a relationship, just add a column on Table A, the paste in the following 

 

Degree = RELATED('Table B'[Degree])

 

Karlos_0-1597852339311.png

 

View solution in original post

amitchandak
Super User
Super User

@Anonymous , one is merge table in edit query

https://radacad.com/append-vs-merge-in-power-bi-and-power-query

 

Dax way

https://www.sqlbi.com/articles/from-sql-to-dax-joining-tables/

 

New column in Table A

maxx(filter('Table B', 'Table A'[ID] ='Table B'[User ID]),'Table B'[Degree])

 

 

View solution in original post

5 REPLIES 5
vivran22
Community Champion
Community Champion

@Anonymous 

 

DAX way:

 

LOOKUPVALUE (when there is no relationship between tables)

 

Add a new column using following DAX

Degree = LOOKUPVALUE('Table B'[Degree],'Table B'[ID],'Table A'[ID])

 

RELATED (When the tables are related)

Degree 2 = RELATED('Table B'[Degree])

 

Related article:

https://www.vivran.in/post/dax-lookupvalue

https://www.vivran.in/post/dax-data-modeling-with-related-relatedtable

 

Cheers!
Vivek

If it helps, please mark it as a solution. Kudos would be a cherry on the top 🙂
If it doesn't, then please share a sample data along with the expected results (preferably an excel file and not an image)

Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter

vivran22
Community Champion
Community Champion

Hello @Anonymous

 

Power Query way: Merge Queries

 

With Table A selected > Home > Merge Queries:

vivran22_0-1597894478571.png

 

Select Table B in the second table and select the common column (ID in this case):

vivran22_1-1597894558330.png

 

Under Join Kind, select Left Outer. Click Ok

 

Expand the table > Select the required column from Table B

vivran22_2-1597894705535.png

 

Click Ok.

 

Output:

vivran22_3-1597894781096.png

 

For more details, you may refer to the following:

https://www.vivran.in/post/bi-simplified-webinar-1-p4-merge-queries

https://www.vivran.in/post/vlookup-joins-using-power-query

 

amitchandak
Super User
Super User

@Anonymous , one is merge table in edit query

https://radacad.com/append-vs-merge-in-power-bi-and-power-query

 

Dax way

https://www.sqlbi.com/articles/from-sql-to-dax-joining-tables/

 

New column in Table A

maxx(filter('Table B', 'Table A'[ID] ='Table B'[User ID]),'Table B'[Degree])

 

 

Anonymous
Not applicable

Providing you have a relationship, just add a column on Table A, the paste in the following 

 

Degree = RELATED('Table B'[Degree])

 

Karlos_0-1597852339311.png

 

What should we do if those tables have many to many relationships?

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.

Top Solution Authors