Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
lukaspowerbi
Helper II
Helper II

Joining multiple tables/queries

I am trying to build a summary table displaying countries in one column and some numbers (Members,Joins,Expires) for those countries in other columns.

 

That is my desired (simplified) result:

Country      Members       Joins    Expires

Canada       50                  20        15

USA            80                  30         25

UK              40                  25        10

 

The way I have it set up now is having 3 seperate queries/tables (Members,Joins,Expires) each query feeds one report.

In other words, my members report has a table displaying Country and Members columns,

                         my Joins report has a table displaying Country and Joins columns,

                         and same for Expires, a table displaying Country and Expires columns.

Current State:

Country      Members      

Canada       50                  

USA            80                  

UK              40             

 

Country         Joins   

Canada          20       

USA               30       

UK                 25   

 

Country      Expires

Canada       15

USA            25

UK              10

    

The way these three tables are created is using a distinct member ID per country.

Any thoughts?

 

 

 

 

1 ACCEPTED SOLUTION

Hi @lukaspowerbi

 

Sorry for the late reply.  Did you get this one sorted?

 

I'm guessing there is a subtle difference in the spelling, or even a rogue space that needs to be cleaned for an exact match


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

6 REPLIES 6
lukaspowerbi
Helper II
Helper II

Hi @Phil_Seamark

I am not sure what's easier to explain so that I can accomplish this whether dax or merging queries.....

 

I am not sure if merging queries solves the problem. Can you give me an example of how to merge let's say two tables/queries?

In both tables there are countries that may not be in another table. 

 

Country      Members      

Canada       50                  

USA            80                  

UK              40   

Brazil          20         

 

Country         Joins   

Canada          20       

USA               30   

UK                 25

Australia        10 

 

My desired output is to combine all countries in both columns:

Country      Members     Joins 

Canada       50                  20

USA            80                  30

UK              40                  25

Brazil          20                  0

Australia     0                    10

 

Member IDs per country is the formula (2 columns)

Hope it makes sense.

 

HI @lukaspowerbi,

 

In the Query Editor, I created the following two tables.

 

Table1

image.png

and Table2

 

image.png

I then chose the Merge Queries as New option

 

image.png

I then configure the Merge dialog as follows.  Be sure to click the Country column in bot tables. 

 

image.png

In the newly created table, click the "expand columns" button in the top right hand corner

 

image.png

Configure the dialog as follows and click ok

 

image.png

Now add a new column to combine the two contry fields as follows

 

image.png

 

Delete the 1st and 3rd columns ("Country" and "Table2.Country"), and rename the 5th column from "Custom" to "Country".

 

Highlight the 1st and 2nd columns and use the Replace Values function on the Home table to convert nulls to zeros.

 

image.png

 

Then rename, and reorder your columns and you are good to go.

 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hi @Phil_Seamark.
You have been a great help. Thank you!!!

 

I have one more thing that I would like to ask you about if there is a way to do some work around.

I added a custom column and replaced null values from the first Country column by values in the 5th column.
However, there is Papua New Guinea that causes a bit issue. I attached a screenshot where I highlighted the issue in the pic below.

 

 

 

 

Capture.JPG

 

 

Hi @lukaspowerbi

 

Sorry for the late reply.  Did you get this one sorted?

 

I'm guessing there is a subtle difference in the spelling, or even a rogue space that needs to be cleaned for an exact match


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @lukaspowerbi

 

Have you considered merging the tables using then Query Editor?  

 

image.png

 

This will allow you to create a new table that looks like your desired output.

 

Otherwise we can do this in DAX if you prefer


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Thank you.

I think I'll ttry to use the merge queries function and see how it goes. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.