title: How to calculate a ratio between fields during aggregation in Kibana (5.4.0)?
body: <p>I appreciate if I can get help with my issue. I am really stuck with this...</p>
  
  <p>I have a time series event like below.</p>
  
  <p><a href="https://i.stack.imgur.com/1sWv1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1sWv1.png" alt="timeseries events"></a></p>
  
  <p>From above time series , I am trying to make below histogram aggregation.</p>
  
  <p><a href="https://i.stack.imgur.com/8t5lq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8t5lq.png" alt="histogram aggregation"></a></p>
  
  <p>My final goal is to draw a chart like below.</p>
  
  <p><a href="https://i.stack.imgur.com/rkpVl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rkpVl.png" alt="double y-axis chart"></a></p>
  
  <p>I see that histogram aggregation in visualization can generates data points for <em>score</em> and <em>counts</em> . But I cannot create the ratio between <em>counts</em> and <em>cumulative sum of counts</em>.</p>
  
  <p>How can I create the ratio and draw a double y-axis chart in Kibana?</p>