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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

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 reference table - Microsoft Fabric Community

However, I have one wrinkle that I can't seem to get around.  

The tables have, for lack of a better term, two keys. 

Basically, every location also has a condition.  What I want to do is multiply the reference value against the location that has the same condition

 

DESIRED VALUE = Location with same condition multiplied by the corresponding value in the reference table.  

I've joined the tables by the location column, but can't seem to write a measure that does what I need.  Below is where I get stuck.  I tried unpivoting the columns but that creates a many to many relationship due to multiple locations in a reference table, and I still get stuck on how to write the measure.  

 

Reference Table Attempt

Measure =
SUMX (
    'Main Table';
    'Main Table'[Value] * RELATED ( 'Reference Table'[???] )
)

 

Reference Table Unpivoted Attempt

Unpivot Measure =
SUMX (
    'Main Table';
    'Main Table'[Value] * RELATED ( 'Reference Table'[Value] (? WHERE Attribute = 'Main Table'[Condition] ?)
)

 


Below is sample data.  Note in the live data there are hundreds of conditions: 

Main Table: 

LocationCondition Value
UptownA10
UptownA20
UptownB30
DowntownA40
DowntownB50
DowntownB60

 

Reference Table (A and B are the same conditions as the above table): 

LocationAB
Uptown.5.6
Downtown.4.7

 

Reference Table Unpviot A & B

LocationAttributeValue

Uptown

A.5
UptownB.6
DowntownA.4
DowntownB.7

 

Expected result: 

LocationAB
Uptown35 (70 * .5)18 (30 * .6)
Downtown16 (40 * .4)77 (110 * .7)

 

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

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):

image.png

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:
image.png
Hopefully, this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

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):

image.png

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:
image.png
Hopefully, this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

That got it @TomMartens !  Thanks an absolute ton! 

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.