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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
sdelice
New Member

How to merge two tables in DAX like a full join in SQL

Hi All, 
I search on this forum but i did'nt found exaclty my answer. 
I have to table that countains country datas loade from two differents datasource and could have differents fields. For example if i had two tables of countries, some countries could be in one but not in the auther. I want to have e result table with all countries found in this two tables.

 

Country A
CodeName
FRFrance 
USUnited States
ITItaly

 

 

Country B
CodeNameContinent
FRFranceEurope
GBUnitedEurope
ESSpainEurope
USUnited StatesAmerica


I want to replicate a SQL full join so as to merge this to table and get this results : 

 

Merged Country
CodeNameContinent
FRFrance Europe
USUnited StatesEurope
ITItaly 
GBUnitedEurope
ESSpainEurope


Can anynone help me, that's very urgent...

1 REPLY 1
Anonymous
Not applicable

This should be done in Power Query or SQL, in a word in the ETL layer, not in DAX. But here's the DAX if you really want to do it:

 

[Merged Table] =
generateall(
	distinct(
		union(
			selectcolumns(
				'Country A',
				"Code", 'Country A'[Code],
				"Name", 'Country A'[Name]
			),
			selectcolumns(
				'Country B',
				"Code", 'Country B'[Code],
				"Name", 'Country B'[Name]
			)
		)
	),
	var __code = [Code]
	var __continent =
		max(
			filter(
				'Country B',
				'Country B'[Code] = __code
			),
			'Country B'[Continent]
		)
	return
		row("Continent", __continent)
)

Best

Darek

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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