title: SUM in asp .net report viewer based on condition
body: <p>I have table =></p>
  
  <pre><code>Main Table  : MT
  ================
  PK SPK Name D1 
  ==============
  1, 0, XYZ, 0
  1, 1, A, 99
  1, 2, B, 88
  1, 3, C, 77
  2, 0, NULL, 0
  2, 1, NULL, 99
  2, 2, Z, 88
  </code></pre>
  
  <p>Now, both database and report viewer is <strong><em>exactly</em></strong> showing above pattern.
  I want SUM of D1 in first row for each PK where SPK=0.
  To display D1 fields in report viewer I tried this</p>
  
  <pre><code>=IIF(Fields!SPK.Value=0,SUM(Fields!D1.Value),Fields!D1.Value)
  </code></pre>
  
  <p>But I am wrong here. In report viewer also I am getting same above displayed table.
  I want the total of all Values where SPK is 0 for every PK in First row. But I do not get the first row as Total where SPK=0.
  Also, D1 is always 0 where SPK=0 from database for which row I want to display SUM.</p>
  
  <p><strong>Any way to get the SUM of D1 in first row instead of 0 where SPK=0?</strong></p>