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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Many to Many relationship

Dear Community Members,

 

My fact table is Indices table and have joined the Market Basket table using many to many relationship . I am trying to achieve average weighted indexvalue by years. Market Basket is a portfolio name which has multiple indices. The Indices table has the Index Value which is the avg. monthly price for all the indices in the Market Basket table . [% of Cost Element] are weights of the index in the portfolio

 

Would really appreciate any ideas.  

 

Market Basket Table

anwpowerbi_2-1633740677641.png

 

Model View

 

anwpowerbi_1-1633739038767.png

 

 

anwpowerbi_0-1633737835546.png

 

 

 

1 ACCEPTED SOLUTION

You can use TREATAS or CROSSFITER to do the calculation, but avoid using many-to-many relationships.

In this example:

model.JPG

 You can use the following to calculate the weight by channel (the common field in both tables is only "Item"

Using TREATAS

 

Sum weight by channel =
CALCULATE (
    [Sum Weight],
    TREATAS ( VALUES ( 'Sales Table'[Item] ), 'Weight Table'[Item] )
)

 

Or using CROSSFILTER

SUM of Weight (CROSSFILTER) =
CALCULATE (
    [Sum Weight],
    CROSSFILTER ( 'Sales Table'[Item], 'Dim Item'[Item], BOTH )
)

To get:

Result.JPG

The choice really depends on the performance of each measure in your model (in my example they perform pretty much the same.

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

5 REPLIES 5
PaulDBrown
Community Champion
Community Champion

You should create a dimension table with unique values of the Series ID field covering the range of values present in both tables. Join the Series ID field from the new dimension table to the corresponding fields in both fact tables in one-to-many relationships. You then use the field from the dimension table in your measures, visuals, slicers, filters.....





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Paul, this is what I was thinking, however, the users won't select/slice the data by Series ID. Infact the only Slicers available to the users would be [Category] and [Market Basket]. So then with a bridge table how would I get the weights? I need to calculate the  average weighted indexvalue by years for each market basket 

You can use TREATAS or CROSSFITER to do the calculation, but avoid using many-to-many relationships.

In this example:

model.JPG

 You can use the following to calculate the weight by channel (the common field in both tables is only "Item"

Using TREATAS

 

Sum weight by channel =
CALCULATE (
    [Sum Weight],
    TREATAS ( VALUES ( 'Sales Table'[Item] ), 'Weight Table'[Item] )
)

 

Or using CROSSFILTER

SUM of Weight (CROSSFILTER) =
CALCULATE (
    [Sum Weight],
    CROSSFILTER ( 'Sales Table'[Item], 'Dim Item'[Item], BOTH )
)

To get:

Result.JPG

The choice really depends on the performance of each measure in your model (in my example they perform pretty much the same.

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Can you show a depiction of the visual you need?

It would also be very helpful if you provided sample data or PBIX file to work with





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hi @Anonymous ,

Try connecting the Market Basket table to the bridge table using the slicer ID. The Relationship should be a many to One respectively and the direction should be from Market Basket to Bridge table. That way any selection made in the columns of the Market Basket table will accordingly modify the Bridge table.

 

This Brige table should then be connected to the Indices table with a One to Many relationship and direction should be from Bridge table to Indices table. That way the Bridge table selection would flow to Indices table

 

Can you check if this works?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.