title: SSRS Lookup combined with SUM IIF
body: <p>I have the following situation (in SQL Server 2008 R2):</p>
  
  <p><a href="https://i.stack.imgur.com/edfDW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/edfDW.png" alt="enter image description here"></a></p>
  
  <pre><code>. Two datasets (Dataset 1 / Dataset 2) 
  . Rows (A - H ) &lt;br&gt;
  . Columns (2011 - 2012 - 2013 - P12 M) 
  </code></pre>
  
  <p>I recieve the first three columns from dataset 1, the last column (Past 12 Months) with an <code>lookup</code> 
  on </p>
  
  <pre><code>Column A=Lookup(Fields!A.Value, Fields!A.Value, Fields!Total.Value, "Dataset 2")
  </code></pre>
  
  <p>So far so good.. </p>
  
  <p>The challenging part: <br></p>
  
  <pre><code>Row B/A = ROW B divided by ROW A 
  </code></pre>
  
  <p>I use this statement: <br></p>
  
  <pre><code>=SUM(IIF( Fields!A.Value = "B", Fields!Total.Value, 0)) / SUM(IIF( Fields!A.Value = "A", Fields!Total.Value, 0)) 
  </code></pre>
  
  <p>But how to get there with an lookup?
  How to get to the first question mark (Answer: 2,23)? <br><br></p>
  
  <p>I tried to combine the statement with an <code>lookup</code>, so far no result. <br>
  Searched the internet and found/tried some URL: <br>
  <a href="https://stackoverflow.com/questions/21993846/ssrs-nested-iif-expression-in-lookup">SSRS nested iif expression in lookup</a></p>