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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Jtbonner1986
Helper I
Helper I

Fix a Many to Many relationship? How to build correct data model...

Hi Everyone, 

 

I have an issue i want to resolve and im not sure of the best way;

 

I have two tables with mulitple rows for 'Material ID'; one is a 'Demand' table and one is a 'Product' Table. I want to be able to filter on one 'Material ID' and for it to return only the values of that material in the demand table. 

 

The tables are structured like the below

 

Demand Table 

Material No.Date RequiredQuantity
12301/02/202350
45601/02/202325
78901/02/202310
12301/03/202310
12301/04/20235
12301/02/202310

 

Product Table

 

Product IDMaterial IDQTY Needed
AAA1235
AAA7891
BBB9991
BBB1231
CCC5551
CCC12310

 

I want to create a Matrix visual that displays the Demand table like the below (using a pre created Calendar table)

 

and i want to be able to filter by Product ID - and for it toonly return the Material ID relating to the product. 

 

Material ID01/02/202301/03/202301/04/2023
12360105
45625  
78910 

 

 

But i am unbable to join both tables on Material ID as there are multiple rows for this in the Demand and the Product table as a single material can below to multiple products

 

any help is really appreciated 

 

Many thanks,

Josh

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Jtbonner1986 ,

Please create a measure like:

Measure = 
VAR _material = SELECTEDVALUE('Product'[Material ID])
VAR _value = CALCULATE(SUM('Demand'[Quantity]),'Demand'[Material No.]=_material)
RETURN
_value

Output:

vcgaomsft_0-1692681869765.png

Please check the pbix file.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Jtbonner1986 ,

Please create a measure like:

Measure = 
VAR _material = SELECTEDVALUE('Product'[Material ID])
VAR _value = CALCULATE(SUM('Demand'[Quantity]),'Demand'[Material No.]=_material)
RETURN
_value

Output:

vcgaomsft_0-1692681869765.png

Please check the pbix file.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Idrissshatila
Super User
Super User

Hello @Jtbonner1986 ,

 

This video will show you how to create this dimension table https://youtu.be/dN3QYYbdk9c

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin
Vote For my Idea 💡



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Idrissshatila
Super User
Super User

Hello @Jtbonner1986 ,

 

You should build it as a star shcema Model, check this microsoft documentation to learn how https://learn.microsoft.com/en-us/power-bi/guidance/star-schema

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin
Vote For my Idea💡

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




What is the fact table here? Sorry for being stupid.... But as i could do with as much info as possible rather than... Just build the right schema 😄

Hello @Jtbonner1986 ,

 

so they are both fact tables, now create a table that had the material ID without duplicates to be the dimension and link it to both tables through the material ID. then use it to filter by material ID.

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin
Vote For my Idea 💡



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




This is back to the original queation. I need to filter the report by Product. Each Product has multiple Material ID's and the same material ID feature across multiple products, so how can i create a single Dimension table with material ID linked to multiple products?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors