Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Multiply Table by a Reference Table With Conditions

Hello!  I'm looking for a solution to multiply values in a main table with ones in a reference table.  My problem is very similar to this solved solution: Solved: Help with Multiply columns by refere...
  • TomMartens's avatar
    2 years ago

    Hey Anonymous ,

     

    this is my measure:

     

    Measure = 
    sumx(
        'Main Table'
        , var currentLocation = [Location]
        var currentCondition = [Condition ]
        return
        'Main Table'[Value] 
        * 
        CALCULATE( SUM( 'Reference Table Unpviot A & B'[Value] ) 
            , 'Reference Table Unpviot A & B'[Location] = currentLocation 
            , 'Reference Table Unpviot A & B'[Attribute] = currentCondition 
        )
    )

     

    This is a simple Matrix visual (build by the columns of the Main table):

    Please check the expected result for Location Uptown and Condition A, it seems the provided data does not match with the expected result.

    You can not create a measure that reacts on different columns, at least not if you want the solution fully dynamic, independent of the "number" of conditions, for this reason I use the unpivoted table, but do not try to create any relationship.
    Please be aware that in my solution the Main Table and the "Reference Table Unpivot ..." are not related, this are the only two table of the model:

    Hopefully, this provides what you are looking for.

     

    Regards,

    Tom