title: Conditional distinct count based on a measure in DAX
body: <p>I am trying to do this with DAX and unable to get the correct distinct count...</p>
  
  <pre><code>AccountID   OrderDate   Product     SalesAmount DiscountAmount
  1023        Nov-14      Product001  $0          $5.00
  1045        Nov-14      Product001  $30.00  $10.00
  1023        Nov-14      Product002  $1.00       $0  
  1089        Nov-14      Product001  $0          $5.00
  2045        Nov-14      Product001  $50.00  $25.00
  1045        Nov-14      Product001  $(30.00)    $0 
  </code></pre>
  
  <p><strong>Q1.</strong> How do I count Distinct Customers where Total Sales Amount was $0 (Answer is 2, 1045, 1089) - see here I want to ignore 1023 because the total Sales amount for that account is not $0.  </p>
  
  <p>I tried to create a measure: </p>
  
  <pre><code>TotalCustomers:=CALCULATE(DISTINCTCOUNT(Table1[AccountID]), 'Table1')
  </code></pre>
  
  <p>And then added this: </p>
  
  <pre><code>ZeroCustomers:=CALCULATE([TotalCustomers], FILTER('Table1', [Sum of SalesAmount]&lt;&gt;0))
  </code></pre>
  
  <p>But account 1023 gets counted and I get '3' for ZeroCutomers</p>
  
  <p><strong>Q2.</strong> How do I add up DiscountAmount for Customers where Total Sales Amount was $0 (Answer $15)</p>
  
  <p>This is an extension to Q1 - once I have figure out Q1 - I can probably figure this one out.</p>
  
  <p>My other choice is to create a new table already summarized by AccountID - but then I wont be able to use slicer since I still want to slice by lets say Product and other Dimensions.</p>
  
  <p>Any help will be appreciated!</p>
  
  <p>Thanks!</p>