The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
In my report, I would like one table that shows the title and status. Data comes from two different tables. When I attempt to use Merge Queries into new and select title in both tables, it brings over ALL of the first tables columns and not merging the title column I selected. Given I can only do one column using merge, is there a better method?
I also want to identify what table the data came from as a new column.
Solved! Go to Solution.
Hi,
Thanks for the solution @asadmd93 offered, and i want to offer some more information for user to refer to.
hello @deeave , if you want to the same columns in two tables, you can refer to the follwing sample.
Sample data
Table A
Table B
Create a blank query, then input the following code in advanced editor.
let
Columnname=List.Intersect({Table.ColumnNames(#"Table A"),Table.ColumnNames(#"Table B")}),
Source1=Table.SelectColumns(#"Table A",Columnname),
Source2=Table.SelectColumns(#"Table B",Columnname),
Combine=Table.Combine({Source1, Source2})
in
Combine
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Thanks for the solution @asadmd93 offered, and i want to offer some more information for user to refer to.
hello @deeave , if you want to the same columns in two tables, you can refer to the follwing sample.
Sample data
Table A
Table B
Create a blank query, then input the following code in advanced editor.
let
Columnname=List.Intersect({Table.ColumnNames(#"Table A"),Table.ColumnNames(#"Table B")}),
Source1=Table.SelectColumns(#"Table A",Columnname),
Source2=Table.SelectColumns(#"Table B",Columnname),
Combine=Table.Combine({Source1, Source2})
in
Combine
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This worked perfectly to combine the tables, thank you! I updated the code to create a table to identify the source table so I could display in my report. Code below:
let
// Select the columns from Project_ideas and add SourceTable column
Source1 = Table.AddColumn(
Table.SelectColumns(Project_ideas, {"Service", "Status", "Title"}),
"SourceTable",
each "Project_ideas"
),
// Select the columns from Project_Discovery and add SourceTable column
Source2 = Table.AddColumn(
Table.SelectColumns(Project_Discovery, {"Service", "Status", "Title"}),
"SourceTable",
each "Project_Discovery"
),
// Combine the two tables
CombinedTable = Table.Combine({Source1, Source2})
in
CombinedTable
Use Append queries instead of merge queries. Here is how you can do it:
Load both tables
Append Queries:
Add a Custom Column to Identify the Source Table:
Select Only the Required Columns:
If my post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
119 | |
86 | |
75 | |
55 | |
44 |
User | Count |
---|---|
136 | |
128 | |
78 | |
64 | |
63 |