Reputation: 21
I want to achieve the following:
The idea is to calculate the sum product in the following scenario:
How can I achieve that in DAX?!
Upvotes: 0
Views: 772
Reputation: 7891
It depends a bit on how your data model looks...
With a model like this:
Your DAX measure may look something like this:
Weighted Amount =
SWITCH (
TRUE(),
ISINSCOPE ( Level2[Level 2] ),
SELECTEDVALUE ( Level2[Amount] ),
ISINSCOPE ( Level1[Level 1] ),
SUMX (
Level2,
Level2[Amount] * Level2[Weight 2]
),
SUMX (
Level1,
CALCULATE (
SUMX (
Level2,
Level2[Amount] * Level2[Weight 2]
)
) * Level1[Weight 1]
)
)
We're using SWITCH
and ISINSCOPE
to determine the level at which the measure is being evaluated, then following your business logic for each level.
Upvotes: 1