cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rajiv1237 Regular Visitor
Regular Visitor

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

Accepted Solutions
Rajiv1237 Regular Visitor
Regular Visitor

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

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

 

 

 

4 REPLIES 4
Rajiv1237 Regular Visitor
Regular Visitor

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

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

 

 

 

steph_io Regular Visitor
Regular Visitor

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

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

jatneerjat Member
Member

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

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.

 

 

Domantas Frequent Visitor
Frequent Visitor

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

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