Calculation based on not the primary attribute of the dimension
I have a dimension with two attributes and a fact table. The dimension is linked to the fact table by the primary attribute. Attributes are of the same nature, i.e. the list of possible values is the same. In fact, these are related codes.
Now I can get from the cube next result split by both attributes:
Dim.Item Dim.LinkedItem Facts.Amount
Item1 Item3 10
Item2 Item3 20
Item3 Item2 50
Or like this if I use the second attribute:
Dim.LinkedItem Facts.Amount
Item2 50
Item3 30
I need a calculation that will allow me to get the next result:
Dim.Item Dim.LinkedItem LinkedAmount
Item1 Item3 0
Item2 Item3 50
Item3 Item2 30
In other words, for each value of the main attribute I should get the sum from the fact table, where this value acts as the second attribute.
Please help to write MDX formula for this calculation.