Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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. Marke...
  • PaulDBrown's avatar
    PaulDBrown
    4 years ago

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

    In this example:

     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:

    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