Forum Discussion
Multi level measure with DAX
Hello everyone,
Could you please help me on this calculation ?
I have a table called cost, looks something like this :
| Market | Production center | Year | L1 Cost Structure | L2 Cost Structure | L3 Cost Structure | Cost in Mio USD | Sales Volume in Mio |
| Spain | 1B | 2022 | Consumable material Cat1 | Consumable material L2 Cat1 | Consumable material L3 Cat1 X | 2.3 | 19 |
| Spain | 1B | 2022 | Packagin material Cat1 | Packagin material L2 Cat1 | Packagin material L3 Cat1 Y | 1.7 | 19 |
| Spain | 1B | 2022 | Consumable material Cat1 | Consumable material L2 Cat1 | Consumable material L3 Cat1 Z | 3 | 19 |
| Spain | 1B | 2022 | Packagin material Cat1 | Packagin material L2 Cat1 | Packagin material L3 Cat1 T | 4 | 19 |
the measure i'm trying to create is cost per 1k unit and then plug it on matrix to act as below :
on L3 cost structure the measure should display : (Sum(cost in Mio USD)/Sum(sales volume) )* 1000
on L2 cost structure it would sum the lines of L3 cost structure
on L1 cost structure it would sum the lines of L2 cost structure
methods i have tried :
Method 1:
Thanks.
I end up doing this :SUMX(SUMMARIZE('Cost','Cost'[L1 Cost Structure],'Cost'[L2 Cost Structure],'Cost'[L3 Cost Structure],"CostPerVolume", SUM('Cost'[Cost(M USD)]) / SUM('Cost'[Sales Volume(M)]) * 1000),[CostPerVolume])And it worked. will try the inscope too just to have options in future.
2 Replies
- amitchandak
Super User
T-Ilias , You can use isinscope to handle this, but it work in Bar, Matrix not Table visual
// in method two
SWITCH(TRUE(),
Isinscope('Cost'[L3 Cost Structure]), [L3Level],
Isinscope('Cost'[L2 Cost Structure]), [L2Level],
Isinscope('Cost'[L1 Cost Structure]) , [L1Level]
)IsInScope - Switch Rank at different levels: https://youtu.be/kh0gezKICEM
- T-IliasRegular Visitor
Thanks.
I end up doing this :SUMX(SUMMARIZE('Cost','Cost'[L1 Cost Structure],'Cost'[L2 Cost Structure],'Cost'[L3 Cost Structure],"CostPerVolume", SUM('Cost'[Cost(M USD)]) / SUM('Cost'[Sales Volume(M)]) * 1000),[CostPerVolume])And it worked. will try the inscope too just to have options in future.