title: Tableau: Create a table calculation that sums distinct string values (names) when condition is met
body: <p>I am getting my data from denormalized table, where I keep names and actions (apart from other things). I want to create a calculated field that will return sum of workgroup names but only when there are more than five actions present in DB for given workgroup.</p>
  
  <p>Here's how I have done it when I wanted to check if certain action has been registered for workgroup:</p>
  
  <pre><code>WINDOW_SUM(COUNTD(IF [action] = "ADD" THEN [workgroup_name] END))
  </code></pre>
  
  <p>When I try to do similar thing with count, I am getting "Cannot mix aggregate and non-aggregate arguments":</p>
  
  <pre><code>WINDOW_SUM(COUNTD(IF COUNT([Number of Records]) &gt; 5 THEN [workgroup_name] END))
  </code></pre>
  
  <p>I know that there's problem with the IF clause, but don't know how to fix it.</p>
  
  <p>How to change the IF to be valid? Maybe there's an easier way to do it, that I am missing?</p>
  
  <p>EDIT:
  (after Inox's response)</p>
  
  <p>I know that my problem is mixing aggregate with non-aggregate fields. I can't use filter to do it, because I want to use it later as a part of more complicated view - filtering would destroy the whole idea.</p>