title: Division of two aggregration metric of kibana
body: <p>I want to do the division of two aggregation metric of kibana. I am getting the count of two values and i want to divide both of them.</p>
  
  <p>Is there is any way to do it.</p>
  
  <p>Kibana is generating this elastic search request :</p>
  
  <pre><code>{
    "size": 0,
    "_source": {
      "excludes": []
    },
    "aggs": {
      "1": {
        "sum_bucket": {
          "buckets_path": "1-bucket&gt;_count"
        }
      },
      "2": {
        "cardinality": {
          "field": "ms.keyword"
        }
      },
      "1-bucket": {
        "terms": {
          "field": "ms.keyword",
          "size": 10000,
          "order": {
            "_count": "desc"
          }
        }
      }
    },
    "stored_fields": [
      "*"
    ],
    "script_fields": {
      "indiviualCount": {
        "script": {
          "inline": "(doc['campaign'].empty) ? 0 : ((1.0/doc['campaign'].value) * 100)",
          "lang": "painless"
        }
      }
    },
    "docvalue_fields": [
      "edrTimestamp",
      "timestamp"
    ],
    "query": {
      "bool": {
        "must": [
          {
            "match_all": {}
          }
        ],
        "filter": [],
        "should": [],
        "must_not": []
      }
    }
  }
  </code></pre>
  
  <p>Is there any way we can achieve it in Kibana. I was think to use scripted field but where it will be written. Someone recommended me to use Pipeline aggregation but i am not able to achieve it </p>