Forum Discussion
DJBrennan
9 years agoFrequent Visitor
DAX RELATED not working for me
Hi, i have a fact table which contains many repetitions of a Supply Number with different usage values by date. I have a dim table that contains same supply number and various prices. I want to crea...
- 9 years ago
I would iterate over the values of the dim[price] column or the dim table using one of these two measures:
cost = SUMX ( VALUES ( dim[price] ), dim[price] * CALCULATE ( SUM ( fact[usage] ) ) )
or
cost =
SUMX ( dim, dim[price] * CALCULATE ( SUM ( fact[usage] ) ) )The red part can be replaced with a measure if you have already defined it.
- 9 years ago
In this scenario, since the multiply need to be done on each row level, you need to multiple the RELATED price in SUMX() function.
I assume you have table like below:
You just need to use SUMX() function.
Total Cost = SUMX('Fact','Fact'[Usage]*RELATED(Supply[Price]))Regards,
DJBrennan
9 years agoFrequent Visitor
Yes, of course. that's why the table function perfectly. They're related on Supply Number
de ks
v-sihou-msft
Microsoft Employee
9 years ago
In this scenario, since the multiply need to be done on each row level, you need to multiple the RELATED price in SUMX() function.
I assume you have table like below:
You just need to use SUMX() function.
Total Cost = SUMX('Fact','Fact'[Usage]*RELATED(Supply[Price]))
Regards,