# How to Visualize data created using Bucket Script into dashboard

**URL:** <https://discuss.elastic.co/t/how-to-visualize-data-created-using-bucket-script-into-dashboard/127456>\
**Category:** Kibana\
**Created:** [April 10, 2018, 9:52am UTC](https://discuss.elastic.co/t/how-to-visualize-data-created-using-bucket-script-into-dashboard/127456 "2018-04-10T09:52:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinoz1990](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@vinoz1990](https://discuss.elastic.co/u/vinoz1990)\
**Post date:** [April 10, 2018, 9:52am UTC](https://discuss.elastic.co/t/how-to-visualize-data-created-using-bucket-script-into-dashboard/127456/1 "2018-04-10T09:52:16Z")

</div>

I need to create a cumulative Average and i have created a following bucket script  
**i wanted to display total percentage values in Kibana dashboard**

```auto
GET metricsreport2.0/report/_search
{
  "query":{
    "match_all": {}
  },
    "size": 0,
    "aggs" : {
      "Defects_per_month" : {
            "date_histogram" : {
                "field" : "Go-LiveDate",
                "interval" : "month"
            },       
      "aggs":{
        "sales": {
                    "sum": {
                        "field": "DefectDensity"
                    }
                },
      "totalsum": {
        "cumulative_sum": {
            "buckets_path": "sales" 
               }
              },
      "totalcount": {
        "value_count" : { "field" : "DefectDensity" }
                    },
            "totalsumcount": {
        "cumulative_sum": {
            "buckets_path": "totalcount" 
               }
              } ,
               "totalpercentage": {
                    "bucket_script": {
                        "buckets_path": {
                          "totalcumulativesum": "totalsum",
                          "totalcumulativesum": "totalsumcount"
                        },
                        "script": "params.totalcumulativesum/ params.totalcumulativesum"
                    }
                }
      }
      }
    }
}

```

**and the response as follows**

```auto
{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 52,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "Defects_per_month": {
      "buckets": [
        {
          "key_as_string": "2017-02-01T00:00:00.000Z",
          "key": 1485907200000,
          "doc_count": 1,
          "totalcount": {
            "value": 1
          },
          "sales": {
            "value": 23.809524536132812
          },
          "totalsum": {
            "value": 23.809524536132812
          },
          "totalsumcount": {
            "value": 1
          },
          "totalpercentage": {
            "value": 23.809524536132812
          }
        },
        {
          "key_as_string": "2017-03-01T00:00:00.000Z",
          "key": 1488326400000,
          "doc_count": 12,
          "totalcount": {
            "value": 12
          },
          "sales": {
            "value": 567.7753524780273
          },
          "totalsum": {
            "value": 591.5848770141602
          },
          "totalsumcount": {
            "value": 13
          },
          "totalpercentage": {
            "value": 45.50652900108924
          }
        },
        {
          "key_as_string": "2017-04-01T00:00:00.000Z",
          "key": 1491004800000,
          "doc_count": 4,
          "totalcount": {
            "value": 4
          },
          "sales": {
            "value": 265.74769401550293
          },
          "totalsum": {
            "value": 857.3325710296631
          },
          "totalsumcount": {
            "value": 17
          },
          "totalpercentage": {
            "value": 50.43132770762724
          }
        },
        {
          "key_as_string": "2017-05-01T00:00:00.000Z",
          "key": 1493596800000,
          "doc_count": 8,
          "totalcount": {
            "value": 8
          },
          "sales": {
            "value": 507.05126571655273
          },
          "totalsum": {
            "value": 1364.3838367462158
          },
          "totalsumcount": {
            "value": 25
          },
          "totalpercentage": {
            "value": 54.575353469848636
          }
        },
        {
          "key_as_string": "2017-06-01T00:00:00.000Z",
          "key": 1496275200000,
          "doc_count": 13,
          "totalcount": {
            "value": 13
          },
          "sales": {
            "value": 357.329167842865
          },
          "totalsum": {
            "value": 1721.7130045890808
          },
          "totalsumcount": {
            "value": 38
          },
          "totalpercentage": {
            "value": 45.308236962870545
          }
        },
        {
          "key_as_string": "2017-07-01T00:00:00.000Z",
          "key": 1498867200000,
          "doc_count": 5,
          "totalcount": {
            "value": 5
          },
          "sales": {
            "value": 0
          },
          "totalsum": {
            "value": 1721.7130045890808
          },
          "totalsumcount": {
            "value": 43
          },
          "totalpercentage": {
            "value": 40.039837316025135
          }
        }
      ]
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)\
**Post date:** [April 10, 2018, 6:53pm UTC](https://discuss.elastic.co/t/how-to-visualize-data-created-using-bucket-script-into-dashboard/127456/2 "2018-04-10T18:53:32Z")

</div>

Hi there, we don't currently support bucket scripts in Kibana. Please see [Bucket script aggregation](https://discuss.elastic.co/t/bucket-script-aggregation/27325/7) for a prior discussion. You can follow this [GitHub issue](https://github.com/elastic/kibana/issues/4707) for progress on this feature request.

Thanks,  
CJ

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 8, 2018, 6:53pm UTC](https://discuss.elastic.co/t/how-to-visualize-data-created-using-bucket-script-into-dashboard/127456/3 "2018-05-08T18:53:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
