title: Calculation based on not the primary attribute of the dimension
body: <p>Calculation based on not the primary attribute of the dimension</p>
  
  <p>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.</p>
  
  <p>Now I can get from the cube next result split by both attributes:</p>
  
  <pre><code>Dim.Item    Dim.LinkedItem  Facts.Amount
  
  Item1       Item3           10
  
  Item2       Item3           20
  
  Item3       Item2           50
  </code></pre>
  
  <p>Or like this if I use the second attribute:</p>
  
  <pre><code>Dim.LinkedItem  Facts.Amount
  
  Item2           50
  
  Item3           30
  </code></pre>
  
  <p>I need a calculation that will allow me to get the next result:</p>
  
  <pre><code>Dim.Item    Dim.LinkedItem  LinkedAmount
  
  Item1       Item3           0
  
  Item2       Item3           50
  
  Item3       Item2           30
  </code></pre>
  
  <p>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.</p>
  
  <p>Please help to write MDX formula for this calculation.</p>