title: SSRS Count Distinct Fields!B.value Where Fields!A.value =
body: <p>I have a report with two tables.  The first table is a list of clients, detailing each client that falls into one category of three with different items for each client.  The SQL joins up a client_table with the client_items table (there can be multiple items per client) the SQL results looks like so:</p>
  
  <pre><code>Type    ClientID    ItemID
  A       1           1
  A       3           1
  A       3           2
  B       2           1
  B       4           3
  C       5           2
  </code></pre>
  
  <p>My second table is going to return counts of the distinct ClientIDs from various combinations of the types:</p>
  
  <ul>
  <li><p>Total (A+B+C) - I've got this one figured out with <code>=CountDistinct(Fields!ClientID.Value,"datasource1")</code></p></li>
  <li><p>Type B+C - Distinct ClientIDs where the type is B or C</p></li>
  <li><p>Type C - Distinct ClientIDs where the type is C</p></li>
  </ul>
  
  <p>I hope that was clear, if not let me know what I need to add to clear it up.</p>