Do you have a requirement on how to add column from another table in power bi? This Power BI tutorial explains, how to add column from another table in power bi in different ways.
- Add column from another table in Power bi Dax
- Add column from another table in power query
- Adds column from another table Lookup in Power BI
1. Add column from another table in power bi dax
Let us see how to add a column from another table using the Power BI Dax formula with and without the relationship between two tables in Power BI,
In this post, I have used the vehicle sample data, which you can download from here.
Table 1: (Bikes Table)
Table 2: (Cars Table)
Add a column from another table with a relationship between tables in Power BI
Let us see how to add a column from another table with a relationship between two tables in Power BI.
- To make a relationship between two tables, make sure both tables should contain the same column. So that we can make the relationship between the two tables.
Follow the below steps to make a relationship between the two tables:
- Open the Power Bi desktop, and load the two tables into it. In the Model section, select the vertical ellipsis icon and click on the Manage relationships as below:
- In the Manage relationship window, select the tables and columns related to it and click on the ok button.
- The below screenshot represents the cardinality relationship between the two tables.
- Now in the Data section, under the Table tools select the New column option as shown below:
- In the formula bar, apply the below-mentioned formula and click on the check icon,
Column from another table = RELATED(Cars[Car Names])
where,
- Column from another table = New column name,
- Cars = Another Table name
- Car Names = Another Table’s column name
In the below screenshot, you can see that the new column has been added and displays the column data value presented in another table.
This is how to add a column from another table with a relationship between two tables in Power BI.
Read How to create a table in Power bi
Add a column from another table with no relationship between tables in Power BI
Let us see how we can add a column from another table with no relationship between two tables in Power BI,
- Initially open the Power BI desktop and load the two tables’ data into it. In the Model section make sure that the tables have no cardinality relationship as below:
- In the Data section, under the Table tools select the New column option, and in the formula bar, apply the below-mentioned formula and click on the check icon:
Column data from another table =
var Color = Bikes[Color]
var CarModel = CALCULATE(MAX(Cars[Car Model]),Cars[Color]= Color)
return CarModel
where,
- Column data from another table = New column name,
- Color, CarModel = Variable names
- Bikes = Another Table name
- Car Model,Color = Column names
- In the below screenshot, you can see that the new column has been added and displays the column data value presented in another table.
This is how to add a column from another table with no relationship between two tables in Power BI.
This is how to add a column from another table using the Power BI Dax formula with and without the relationship between two tables in Power BI.
Read Power Bi Table Manipulation Functions
2. Add column from another table in Power query
Let us see how to add the index column using the power query editor in Power BI,
In this example, I’ll add the index column from index 1 in the vehicles table data.
- Open the Power BI desktop, and load the table data into it, In the ribbon, under the Home option click on the Transform data option.
- It will redirect to the power query editor, select the table for which you want to add an index column, and in the ribbon choose the Add column option.
- Expand the index column and choose the starting index, either we can select index 0, index 1, or custom index.
- Click on the close and Apply option, so that changes will appear on the Power BI desktop.
= Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type)
- In the below screenshot, you can see the newly created index column in the vehicle table data.
This is how to add the index column using the power query editor in Power BI.
3. Add a column from another table lookup in Power BI
Let us see how to add a column from another table using the LookUp function in Power BI,
- Initially open the Power BI desktop and load the two tables’ data into it.
- In the Data section, under the Table tools select the New column option, and in the formula bar, apply the below-mentioned formula and click on the check icon:
Column data from another table= LOOKUPVALUE(Bikes[Bike Names],Bikes[Color],Cars[Color])
where,
- Column data from another table = New column name,
- Bikes = Another Table name
- Bike Names,Color = Column names
- In the below screenshot, you can see that the new column has been added and displays the column data value presented in another table.
This is how to add a column from another table using the LookUp function in Power BI.
This Power Bi tutorial explained, how to add columns from another table in Power BI in different ways. It will fix the below issues.
- Add column from another table power bi Dax
- Add a column from another table with a relationship between tables
- Add a column from another table with no relationship between the tables
- Add a column from another table in the power query
- Power Bi adds a column from another table Lookup
- add column from another table in power bi
- add column from another table in power bi dax
- add column from another table in power query
- add column from different table power bi
- add columns from different tables power bi dax
- adding two columns from different tables in power bi
- power bi add column from another table in the query editor
You may like the following Power BI tutorials:
- Power BI combine columns from two tables
- Power bi create a date table
- Power Bi Time Intelligence Function
- Power BI Information Functions
- Power Bi count function
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com