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
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
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.

Top Solution Authors