title: Using filtered results as field for calculated field in Tableau
body: <p>I have a table that looks like this:</p>
  
  <pre><code>+------------+-----------+---------------+
  | Invoice_ID | Charge_ID | Charge_Amount |
  +------------+-----------+---------------+
  |          1 | A         | $10           |
  |          1 | B         | $20           |
  |          2 | A         | $10           |
  |          2 | B         | $20           |
  |          2 | C         | $30           |
  |          3 | C         | $30           |
  |          3 | D         | $40           |
  +------------+-----------+---------------+
  </code></pre>
  
  <p>In Tableau, how can I have a field that <code>SUMs</code> the <code>Charge_Amount</code> for the <code>Charge_IDs</code> B, C and D, where the invoice has a <code>Charge_ID</code> of A? The result would be $70.</p>
  
  <p>My datasource is SQL Server, so I was thinking that I could add a field (called <code>Has_ChargeID_A</code>) to the SQL Server Table that tells if the invoice has a <code>Charge_ID</code> of A, and then in Tableau just do a <code>SUM</code> of all the rows where <code>Has_ChargeID_A</code> is true and <code>Charge_ID</code> is either B, C or D. But I would prefer if I can do this directly in Tableau (not this exactly, but anything that will get me to the same result).</p>