# Visualizing Weighted Average Aggregation in Kibana

**URL:** <https://discuss.elastic.co/t/visualizing-weighted-average-aggregation-in-kibana/269901>\
**Category:** Kibana\
**Created:** [April 12, 2021, 3:37pm UTC](https://discuss.elastic.co/t/visualizing-weighted-average-aggregation-in-kibana/269901 "2021-04-12T15:37:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![connersexton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/connersexton/32/86932_2.png) [@connersexton](https://discuss.elastic.co/u/connersexton)\
**Post date:** [April 12, 2021, 3:37pm UTC](https://discuss.elastic.co/t/visualizing-weighted-average-aggregation-in-kibana/269901/1 "2021-04-12T15:37:38Z")

</div>

I've read a lot of documentation regarding single-value weighted average aggregation in Kibana, but can't seem to find anything on the actual application of this in a dashboard or visualization. My knowledge of Kibana syntax is limited, therefore I rely mostly on the point-and-click functionality offered in Kibana's "Visualize" feature.

I am trying to visualize a bar chart that reflects the weighted average of a single field. I have the field that must be averaged as well as another field that contains the corresponding weights. Is it possible to create a weighted average aggregation using these fields and visualize this in a bar chart? Thanks!

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [April 12, 2021, 3:55pm UTC](https://discuss.elastic.co/t/visualizing-weighted-average-aggregation-in-kibana/269901/2 "2021-04-12T15:55:42Z")

</div>

Hi, we maintain a list of supported aggregations by visualization in Kibana: [Supported features by panel type | Kibana Guide [7.12] | Elastic](https://www.elastic.co/guide/en/kibana/current/aggregation-reference.html)

Unfortunately, none of our point-and-click tools offer a weighted average. You can use Vega to create a single-metric chart, kind of like this:

```auto
{
  $schema: https://vega.github.io/schema/vega-lite/v4.json
  data: {
    url: {
      %context%: true
      %timefield%: timestamp
      index: kibana_sample_data_flights
      body: {
          aggs: {
            myagg: {
              weighted_avg: {
                value: {
                  field: grade
                }
                weight: {
                  field: weight
                }
              }
            }
          }
          // Speed up the response by only including aggregation results
          size: 0
        }
    }

    format: {property: "aggregations.myagg"}
  }

  mark: text

  encoding: {
    text: {
      field: "value"
      type: quantitative
      format: ".2"
    }
    size: { value: 48 }
  }
}

```

---

<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 10, 2021, 3:55pm UTC](https://discuss.elastic.co/t/visualizing-weighted-average-aggregation-in-kibana/269901/3 "2021-05-10T15:55:50Z")

</div>

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