Power BI: extract columns from a table to another one
I will explain how to insert a specific column from a table to an existing table or using some columns from multiple tables to create a new table. I will begin by adding a new column to an existing table. The first option will be to used the RELATED function (relationship between tables should exists). For instance, RELATED('table'[argument]):

NOTE: make sure that the relationship is from the table to insert (destination) to the table to extract (source) like in the picture and not the contrary

The second option is to do it in the Power Query Editor (in this case, no relationship between tables is needed) by clicking on “transform data -> transform data”:

Click on “home -> merge queries”:

On this popup, I will select the tables/columns to match:

Click on the right icon then select "state":

Now let’s see about creating a new table with an existing column. I will use the SELECTCOLUMNS function (relationship between tables no needed). For instance, SELECTCOLUMNS('table',[argument]):

NOTE: change “table” and “argument” by yours.
This formula will put the same name as “argument” but if I want to put a different name, I will use this one:
SELECTCOLUMNS('table',"different name",[argument])

NOTE: change “different name” by yours.
If I want to add multiple columns, just add another [argument] like that:
- SELECTCOLUMNS('table',[argument1],[argument2])
- SELECTCOLUMNS('table',"different name1",[argument1],"different name2",[argument2])
NOTE: instead to use [argument1], I can use a specific value:
SELECTCOLUMNS('table',"different name1",”specific value”,"different name2",[argument2])

To get only unique values, I will add the DISTINCT function:
DISTINCT(SELECTCOLUMNS('table',"different name1",[argument1]))

To filter a specific criteria, I will add the FILTER function, for instance, if I have a huge data and I want to extract only data for a specific group:
- To get data for a particular criteria:
FILTER(DISTINCT(SELECTCOLUMNS('table',"different name1",[argument1],"different name2",[argument2])),[different name2]="value")
- To exclude blank values:
FILTER(DISTINCT(SELECTCOLUMNS('table',"different name1",[argument1],"different name2",[argument2])),NOT(ISBLANK([different name2])))
NOTE: “different name2” is the new column name where there is the criteria/blank cell(s)
To filter from another table, I will use the CALCULATETABLE function:
SELECTCOLUMNS(CALCULATETABLE('table1',FILTER('table2','table2'[argument]="value")),"different name1",[argument1],"different name2",[argument2])

NOTE: argument1 and argument2 are from table1
Now if I add the UNION function, I will be able to merge columns from 2 different tables into 1 same column:
UNION(SELECTCOLUMNS('table1',[argument]),SELECTCOLUMNS('table2',[argument]))

And to not repeat again, if I want to add more columns or put a particular name, just follow the same formula as above.
Interesting Topics
-
Be successfully certified ITIL 4 Managing Professional
Study, study and study, I couldn’t be successfully certified without studying it, if you are interested...
-
Be successfully certified ITIL 4 Strategic Leader
With my ITIL 4 Managing Professional certification (ITIL MP) in the pocket, it was time to go for the...
-
Hide visual and change background color based on selection
Some small tricks to customize the background colour of a text box...
-
Stacked and clustered column chart or double stacked column chart
In excel, I use a lot the combination of clustered and stacked chart...
-
Refresh Power BI
From the Power BI Service, I can set refresh but, for instance, there is no option to do it monthly or each time a change is made...
-
Power BI alerts to be sent by email from an excel file based on condition
I will explain how to send a list of emails from an excel file after creating alerts...