title: Unable to get SUM of a nested calculated field in Tableau
body: <p>I am trying to get SUM() of a nested calculated field and not able to achieve it.</p>
  <p>I have fields A, B and C. I need to display result for each row as change in A relative to C over time. I am doing that using the formula</p>
  <p>(A- previous A)*(previous B/previous A) / previous C.</p>
  <p>previous meaning value of same category from previous date. So tableau formula looks like this:</p>
  <p>(SUM(A)-LOOKUP(SUM(A), -1))*(LOOKUP(SUM(B),-1)/LOOKUP(SUM(A),-1))/(LOOKUP(MIN(C),-1))</p>
  <p>Applying this formula, result looks right for individual rows but the sum of individual rows is incorrect as it is not adding up the calculated value of each row and instead applying formula on the sum of each variable in the formula.</p>
  <p>So, expected result is 0.6% but tableau is giving 0.9%.</p>
  <p>I tried window_sum() on the calculated field but that returns same result as calculated field.</p>
  <p>How can I get the sum of nested calculated field?
  <a href="https://i.stack.imgur.com/8kFM2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8kFM2.png" alt="enter image description here" /></a></p>