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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rikpatel1998v2
Frequent Visitor

How to join/create relationship between two tables with non unique values?

Hi,

 

I need to create a graph that uses metrics from two different tables. Both the tables do not use any non-unique keys/columns, the only unique thing would be a combination of the different columns.

 

Here is an example of the schema of the two tables:

 

Table 1 has columns + some extra unneccessary columns: 

rikpatel1998v2_0-1668091473890.png

and some metrics lets say metric x y and z

 

Table 2 has similar columns + some extra unneccessary columns:

rikpatel1998v2_1-1668091599139.png

 

Week_commencing is the same as  booking_week_date in the first table while the rest of the columns represent the same thing too. Table 2 has some associated metrics a b c.

 

How can i establish a relationship between these two tables such that I can plot some simple charts that show e.g metric a and metric x on a line chart together, against the booking_week_date/week_commencing, while being filterable by the other columns in the tables (country, city, region etc).

 

I've tried creating a many to many relationship with the date field in both the tables, however, when applying a filter on e.g. destination country, it only works on the metric from which the destination country field was taken from.

 

Thanks

1 ACCEPTED SOLUTION
timg
Solution Sage
Solution Sage

Hi RikPatel,

Here you could make good use of dimensional modelling. This means you create tables in which the descriptive information is separated by topics into dimensions (e.g. in this case you could create a table with all unique dates and a table with all unique locations). you then create a relationship between these dimension tables and the tables containing your metrics (Fact tables). This way, whenever you select a location or date from your dimension table, all fact tables will be filtered. So you can plot metrics from both tables in the same graph.

Hope that helps a bit. Here's an example of a dimensional model from the microsoft learn page for reference: Tutorial: From dimensional model to stunning report in Power BI Desktop - Power BI | Microsoft Learn

 

Best regards,

 

Tim





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
timg
Solution Sage
Solution Sage

Hi RikPatel,

Here you could make good use of dimensional modelling. This means you create tables in which the descriptive information is separated by topics into dimensions (e.g. in this case you could create a table with all unique dates and a table with all unique locations). you then create a relationship between these dimension tables and the tables containing your metrics (Fact tables). This way, whenever you select a location or date from your dimension table, all fact tables will be filtered. So you can plot metrics from both tables in the same graph.

Hope that helps a bit. Here's an example of a dimensional model from the microsoft learn page for reference: Tutorial: From dimensional model to stunning report in Power BI Desktop - Power BI | Microsoft Learn

 

Best regards,

 

Tim





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you Tim!

 

I created unique tables of all the other columns, (calendar table with booking_week_date and week num), a unique country table, unique city table, unique region table and unique sub region table and then established a one to many relationship with the two main tables using these unique tables.

 

I have played around with it and seems like it is working -  I will do some more testing and then mark this as  a solution.

Great to hear it's working!

As a follow-up, instead of multiple location tables you could also make one location table with city, sub-region, region, and country. And then create one relationship between that table and the tables containing metrics. Then you don't need to create a lot of relationships and can still slice 'n dice on all location levels.

Regards and  good luck with the report!

 

Tim





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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