Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Dear colleagues,
I need your help :
I have TWO tables (OPs_dataset and Population)
I would like to create a new table (My_Union_Table) which will combine different columns from these two tables.
Below is my Mesure please could you help me to resolve this issue:
My_Union_Table =
UNION(
SELECTCOLUMNS(
VALUES(OPs_dataset[Country]),
"Country", OPs_dataset[Country],
"Year", SELECTEDVALUE(OPs_dataset[Year]),
"Gen", "DP1",
"Age Group", "12-23 months",
"Mycumul", [Total_DP1_12-23]
SELECTCOLUMNS(
VALUES(Population[Country]),
"Pop_DJ", [DJ]
"Pop_HR", [HR]
Solved! Go to Solution.
Hello @dofrancis3
It would have been beneficial if you had provided a sample dataset your query along with the expected dataset. Nevertheless, have created a sample dataset based on the information.
Here is the OPs_dataset
Here is the Population data:
Union of Tables
If you need combine or append these tables one below the other, you must follow the approach mentioned by
Here is the formatted DAX formula to create a new calculated table:
My_Union_Table (Appended) =
UNION (
SELECTCOLUMNS (
OPs_dataset,
"Country", OPs_dataset[Country],
"Year", OPs_dataset[Year],
"Gen", "DP1",
"Age Group", "12-23 months",
"Mycumul", OPs_dataset[Total_DP1_12-23],
"Pop_DJ", BLANK (),
"Pop_HR", BLANK ()
),
SELECTCOLUMNS (
Population,
"Country", Population[Country],
"Year", BLANK (),
"Gen", BLANK (),
"Age Group", BLANK (),
"Mycumul", BLANK (),
"Pop_DJ", Population[DJ],
"Pop_HR", Population[HR]
)
)
Here is the screenshot of the solution table that you can expect from the above calculated table DAX formula :
If this is the result you want then kindly accept @powerbidev123 reply as the solution
Join of Tables
However, if you wish to join the tables based on the country column to retrieve the remaining data, you may use the following DAX formula.
My_Union_Table =
NATURALINNERJOIN ( OPs_dataset, SELECTCOLUMNS ( Population, [DJ], [HR] ) )
Here is the screenshot of the table that the above DAX will generate:
I am also attaching the Power BI file for your reference.
Best Regards,
Udit
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudo 👍
🚀 Let's Connect: LinkedIn || YouTube || Medium || GitHub
✨ Visit My Linktree: LinkTree
Proud to be a Super User
Thanks for the reply from quantumudit and powerbidev123, please allow me to provide another insight:
Hi, @dofrancis3
Thanks for reaching out to the Microsoft fabric community forum.
Could you please let me know if the responses from quantumudit and powerbidev123 have resolved your issue?If it did, kindly accept it as the solution.
I believe both quantumudit and powerbidev123's suggestions are very effective. quantumudit's response is particularly detailed, while powerbidev123's idea is concise and clear. Their answers align with the format requirements of the UNION function, especially the restriction that both tables must have the same number of columns. Below is a screenshot from the official documentation to help with your understanding:
For more details, please refer to the documentation:
https://learn.microsoft.com/en-us/dax/union-function-dax#remarks
Power Query also has a similar feature called "Append Queries":
For more details, please refer to the documentation:
Append queries - Power Query | Microsoft Learn
Of course, if you have any new discoveries or questions, please feel free to get in touch with us.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello @dofrancis3
It would have been beneficial if you had provided a sample dataset your query along with the expected dataset. Nevertheless, have created a sample dataset based on the information.
Here is the OPs_dataset
Here is the Population data:
Union of Tables
If you need combine or append these tables one below the other, you must follow the approach mentioned by
Here is the formatted DAX formula to create a new calculated table:
My_Union_Table (Appended) =
UNION (
SELECTCOLUMNS (
OPs_dataset,
"Country", OPs_dataset[Country],
"Year", OPs_dataset[Year],
"Gen", "DP1",
"Age Group", "12-23 months",
"Mycumul", OPs_dataset[Total_DP1_12-23],
"Pop_DJ", BLANK (),
"Pop_HR", BLANK ()
),
SELECTCOLUMNS (
Population,
"Country", Population[Country],
"Year", BLANK (),
"Gen", BLANK (),
"Age Group", BLANK (),
"Mycumul", BLANK (),
"Pop_DJ", Population[DJ],
"Pop_HR", Population[HR]
)
)
Here is the screenshot of the solution table that you can expect from the above calculated table DAX formula :
If this is the result you want then kindly accept @powerbidev123 reply as the solution
Join of Tables
However, if you wish to join the tables based on the country column to retrieve the remaining data, you may use the following DAX formula.
My_Union_Table =
NATURALINNERJOIN ( OPs_dataset, SELECTCOLUMNS ( Population, [DJ], [HR] ) )
Here is the screenshot of the table that the above DAX will generate:
I am also attaching the Power BI file for your reference.
Best Regards,
Udit
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudo 👍
🚀 Let's Connect: LinkedIn || YouTube || Medium || GitHub
✨ Visit My Linktree: LinkTree
Proud to be a Super User
Hi @dofrancis3 ,
Union only works with tables of the same column structure. Your two SELECTCOLUMNS statements must have the same column names.
Please check below DAX:
My_Union_Table =
UNION(
SELECTCOLUMNS(
OPs_dataset,
"Country", OPs_dataset[Country],
"Year", OPs_dataset[Year],
"Gen", "DP1",
"Age Group", "12-23 months",
"Mycumul", OPs_dataset[Total_DP1_12-23],
"Pop_DJ", BLANK(),
"Pop_HR", BLANK()
),
SELECTCOLUMNS(
Population,
"Country", Population[Country],
"Year", BLANK(),
"Gen", BLANK(),
"Age Group", BLANK(),
"Mycumul", BLANK(),
"Pop_DJ", Population[DJ],
"Pop_HR", Population[HR]
)
)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
11 | |
10 | |
10 | |
9 |
User | Count |
---|---|
18 | |
13 | |
12 | |
11 | |
8 |