Power BI: calculate value using data from related table

Viewed 334

I'm trying to calculate the value of item by multiple quantity by unit price from related table.

SALES REPORT

ITEMS QTY
A 12
B 30
B 45

UNIT PRICE

ITEMS PRICE
A $5
B $9
2 Answers

If you have a relationship set up between the Sales table and the Unit Price table, you can use the RELATED function to retrieve the price.

Add a DAX calculated column to the SALES REPORT table:

Value = Sales[QTY] * RELATED(Products[PRICE])

You can use LOOKUPVALUE to get the result from the other table if you don't have a relationship defined between the tables. As the link says, RELATED is more efficient.

Value = Sales[QTY] * LOOKUPVALUE(Products[PRICE],Products[ITEMS],Sales[ITEMS])

If your schema is like this S1

Use this measure

Measure = 
SUMX ( RELATEDTABLE ( 'SALES REPORT' ), 'SALES REPORT'[QTY] )
    * SUM ( 'UNIT PRICE'[PRICE] )

S2

Related