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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Rajiv1237
Resolver I
Resolver I

Many to Many Relationship between tables and show data in single Visualization - Power BI

Scenerio:

I have two tables

Table 1: ProductionCollection - It has product and collection amount. Product can repeat

Table 2: ProductSales - It has product and sales amount. Product can repeat.

 

Now I have to create a single visualization that can show product and Sales and collection amount side by side.

 

ProductCollection and ProductSales table cannot be connected because of repeated product values.

1 ACCEPTED SOLUTION
Rajiv1237
Resolver I
Resolver I

We cannot connect Table1: ProductSales and Table2: ProductCollection directly because of many to many relationship. 

Created a bridge table Table3: Product - that has distinct value of product from both tables.

 

Table3: Product table creation

Product = DISTINCT(UNION(DISTINCT(ProductCollection[ProductName]), DISTINCT(ProductSales[ProductName])))

Product = DISTINCT(UNION(DISTINCT(ProductCollection[ProductName]), DISTINCT(ProductSales[ProductName])))

 

ManyToMany_1.PNG

 

 

ManyToMany_2.PNG

 

 

 

View solution in original post

4 REPLIES 4
Rajiv1237
Resolver I
Resolver I

We cannot connect Table1: ProductSales and Table2: ProductCollection directly because of many to many relationship. 

Created a bridge table Table3: Product - that has distinct value of product from both tables.

 

Table3: Product table creation

Product = DISTINCT(UNION(DISTINCT(ProductCollection[ProductName]), DISTINCT(ProductSales[ProductName])))

Product = DISTINCT(UNION(DISTINCT(ProductCollection[ProductName]), DISTINCT(ProductSales[ProductName])))

 

ManyToMany_1.PNG

 

 

ManyToMany_2.PNG

 

 

 

Hi @Rajiv1237,

 

What if we have one more column ProductType and it also has duplicate vlues and we want this column to filter both the tables and also the table product created by us.then how can we create a relationship.

 

 

I have a similar issue, just trying to make a bridge table out of 3 different tables. For some reason my outer DISTINCT doesn't seem to be able to remove duplicates of blank row:
List-Skill groups = DISTINCT(UNION(
    VALUES(AXtimesheets[Skill Group (Category)]),
    VALUES('FTE data lookup only'[Skill group]),
    VALUES('Consolidated Allocations'[Skill group])))

 

So I get two blank values among all other normal names of skill groups.

Then another thing is that for the bridge table there shouldn't be no blanks at all. But to start with if I could find a way to keep only one blank, would be a good start. Any ideas?Capture.PNG

Is there a difference between doing this in M in the Query Editor vs within DAX in the Modeling of the report?

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!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.