# Difference b/w Aggregate & joinaggregate in vega-lite

**URL:** <https://discuss.elastic.co/t/difference-b-w-aggregate-joinaggregate-in-vega-lite/263826>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [February 10, 2021, 6:00am UTC](https://discuss.elastic.co/t/difference-b-w-aggregate-joinaggregate-in-vega-lite/263826 "2021-02-10T06:00:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yashaswini](https://avatars.discourse-cdn.com/v4/letter/y/e68b1a/32.png) [@Yashaswini](https://discuss.elastic.co/u/Yashaswini)\
**Post date:** [February 10, 2021, 6:00am UTC](https://discuss.elastic.co/t/difference-b-w-aggregate-joinaggregate-in-vega-lite/263826/1 "2021-02-10T06:00:32Z")

</div>

When I use aggregate i'm getting value as 0, but when I use joinaggregate i'm proper value.  
Why is this happening ?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/e/8eeaeff025d97b69439825b599dffffd93869c44.png)  
 ![image (1)](https://us1.discourse-cdn.com/elastic/original/3X/b/d/bdff9a12ad1adbdc19c3233a8343e20259703071.png)

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "width": 400,
      data: {
    url: {
      %context%: true
      index: index_dash_performance2
      body: {
        size:10000
        _source: ["StatusOpen"]
        }
      }
      format: {property: "hits.hits"}
    },
  "transform": [
      {"filter": "datum._source.StatusOpen != null"},
      {
        "aggregate": [
        {"op": "sum", "field": "_source.StatusOpen","as": "aud_count"}
        ],
      }
    ],
  "layer": [
 {
    "mark": {
      "type": "text",
      "align": "left",
      "dx": -6,
      "dy": -5
    },
    "encoding": {
      "text": {"field": "aud_count", "type": "quantitative"}
    }
  }]
}

```

---

<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:** [February 16, 2021, 4:12pm UTC](https://discuss.elastic.co/t/difference-b-w-aggregate-joinaggregate-in-vega-lite/263826/2 "2021-02-16T16:12:16Z")

</div>

I think you might be working on the same spec as another Discuss user who I helped out:

> [@Sum operator in stacked bar vega](https://discuss.elastic.co/t/sum-operator-in-stacked-bar-vega/263722/3):
>
> Hi @wylie The main visualization I require is % graph by dividing sum of StatusOpen/ sum of StatusSent, which was not giving expected output in vega-lite. So just wanted to check ouput for simple graph ( with sum of single field). Tried the same spec using sample data, it was giving correct results { "$schema": "https://vega.github.io/schema/vega-lite/v4.json", "description": "Vega-Lite version of bar chart from https://observablehq.com/@d3/learn-d3-scales.", "width": 400, "data…

---

<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:** [March 16, 2021, 4:13pm UTC](https://discuss.elastic.co/t/difference-b-w-aggregate-joinaggregate-in-vega-lite/263826/3 "2021-03-16T16:13:01Z")

</div>

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