title: Count and sum in splunk
body: <p>I have this sets of data:</p>
  <pre><code>name    fruit   location
  
  mary    apple   east
  
  ben pear    east
  
  peter   pear    east
  
  ben apple   north
  
  ben mango   north
  
  peter   mango   north
  
  mary    orange  north
  
  alice   pear    north
  
  janet   pear    north
  
  janet   mango   west
  
  janet   mango   west
  
  peter   mango   west
  
  janet   pear    west
  </code></pre>
  <p>I want to get fields:
  name, number of fruits sent to name, number of fruits sent to name in location</p>
  <p>I tried:</p>
  <blockquote>
  <p>|stats sum(count) as scount_by_name by name</p>
  <p>|stats count as count_by_namelocation (......filled with other formulas......) by name location</p>
  <p>|Table count_by_namelocation scount_by_name</p>
  </blockquote>
  <p>But it does not work, scount_by_name is empty, what's the correct syntax for this?</p>