title: Kibana Timelion: Subselect or Subquery to aggregate sum of max
body: <p>Let's suppose I have the following data on ElasticSearch:</p>
  
  <pre><code>@timestamp; userId; currentPoints
  August 7th 2017, 00:30:37.319; myUserName; 4
  August 7th 2017, 00:43:22.121; myUserName; 10
  August 7th 2017, 00:54:29.177; myUserName; 7
  August 7th 2017, 01:10:29.352; myUserName; 4
  August 7th 2017, 00:32:37.319; myOtherUserName; 12
  August 7th 2017, 00:44:22.121; myOtherUserName; 17
  August 7th 2017, 00:56:29.177; myOtherUserName; 8
  August 7th 2017, 01:18:29.352; myOtherUserName; 11
  </code></pre>
  
  <p>I'm looking to draw a date histogram that will show me the sum of all max:currentPoints per username per hour, which whould generate the following data to plot:</p>
  
  <pre><code>August 7th 2017, 00; SumOfMaxCurrentPoints -&gt; 27 (max from hour 00h from both users 10 + 17)
  August 7th 2017, 00; SumOfMaxCurrentPoints -&gt; 15 (max from hour 01h from both users 4 + 11)
  </code></pre>
  
  <p>This would usually be done with a subquery, extracting the max(currentPoints) for each hour, user and then sum the results and aggregate per hour.</p>
  
  <p>Is this possible with Kibana Timelion for instance? I can't find a way to achieve this using the documentation.</p>
  
  <p>Thanks
  Alex</p>