SELoug
SELoug

Reputation: 60

Create Primary/Foreign key relationship in PowerBi

I have two tables 'CompanyXSales' and 'Market Sales' Each with a primary key, and no primary key / foreign key relationship between the two. I would like to create this relationship, and make the link between these two tables, and therefore, add the column 'MarketSalesId' in 'CompanyXSales' where there will be its key relative to 'MarketSales'. To be a relative key, it suffices to check 3 conditions: -Have the same date -Have the same amount -Have the same country

Here is a sample PowerBiFile

How could i proceed that please ? knowing that i already created a "verify" column (with Dax Formula) in 'MarketSales' which equals to 1 if the conditions are verified 0 if not.

Upvotes: 0

Views: 6128

Answers (1)

Shahab Haidar
Shahab Haidar

Reputation: 641

You can use merge query in Power Query to get the OrderKey Column in MarketSales Table. And then create relationship between both tables.

Please below steps to get the OrderKey Column in MarketSales Table.

  1. Click On Transform Data.
  2. Under Combine Tab click on Merge Queries.
  3. Select all 3 column and use left join.
  4. Click on OK and select the Order Key column as shown below.

enter image description here

Now you can create relationship between both tables

Upvotes: 2

Related Questions