Merge Queries in Power Query Editor

In Power BI we can merge queries, we are combining the data from multiple tables into one based on a column that is common between the tables. This process is like the JOIN clause in SQL.

Step 1: Let’s create the “Students” table.

Power Query M

let
    StudentTable = #table(
        {"Student ID", "Name", "Branch Code"},
        {
            {101, "Ashish", "ELE"},
            {102, "Neha", "MEC"},
            {103, "Raj", "CSE"},
            {104, "Divya", "ELE"},
            {105, "Sunil", "CSE"},
            {106, "Meena", "MEC"},
            {107, "Rakesh", "CIV"},
            {108, "Pooja", "ELE"}
        }
    )
in
    StudentTable       

The output of the above code is shown below:

Merge Queries in Power Query Editor

Step 2: Let’s create the “Branch” table.

Power Query M

let
    BranchTable = #table(
        {"Branch Code", "Branch Name", "HOD"},
        {
            {"ELE", "Electrical", "Dr. Singh"},
            {"MEC", "Mechanical", "Dr. Rao"},
            {"CSE", "Computer Science", "Dr. Gupta"},
            {"CIV", "Civil", "Dr. Mehta"}
        }
    )
in
    BranchTable  

The output of the above code is shown below:

Merge Queries in Power Query Editor

Step 3: Select the Students table and then click on Merge Queries and then Merge Queries as New.

Merge Queries in Power Query Editor

Select the table and its Join Kind. A join kind specifies how a merge operation will be performed.

Merge Queries in Power Query Editor

Note:

There are different Join Kinds:

In the output we can see the rows it is going to return. We can also use the Fuzzy matching operation.

Merge Queries in Power Query Editor

The resultant table is shown in the image below:

Merge Queries in Power Query Editor

Now let’s expand the Branch column.

Merge Queries in Power Query Editor

After expanding, we can see the output table:

Merge Queries in Power Query Editor