# Acessing array in vega lite

**URL:** https://discuss.elastic.co/t/acessing-array-in-vega-lite/203357
**Category:** Kibana
**Tags:** vega
**Created:** [October 13, 2019, 7:34pm UTC](https://discuss.elastic.co/t/acessing-array-in-vega-lite/203357 "2019-10-13T19:34:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Juan\_Grados](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/juan_grados/32/45777_2.png) [@Juan\_Grados](https://discuss.elastic.co/u/Juan_Grados)
#### Post date: [October 13, 2019, 7:34pm UTC](https://discuss.elastic.co/t/acessing-array-in-vega-lite/203357/1 "2019-10-13T19:34:51Z")

</div>

I need to perform an operation in vega-lite/Kibana 6.5 similar to the next one. I need to divide y axis by "data.values[0].b". How can I perform this operation?

```
{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "description": "A simple bar chart with embedded data.",
  "data": {
    "values": [
      {"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43},
      {"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53},
      {"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52}
    ]
  },
  "mark": "bar",
  "encoding": {
    "x": {"field": "a", "type": "ordinal"},
    "y": {"field": "b", "type": "quantitative"}
  }
```

---

<div class="post-metadata">

### Author: ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)
#### Post date: [October 14, 2019, 9:50am UTC](https://discuss.elastic.co/t/acessing-array-in-vega-lite/203357/2 "2019-10-14T09:50:04Z")

</div>

Try this:

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "description": "A simple bar chart with embedded data.",
  "data": {
    "values": [
      {"a": "A", "b": 28},
      {"a": "B", "b": 55},
      {"a": "C", "b": 43},
      {"a": "D", "b": 91},
      {"a": "E", "b": 81},
      {"a": "F", "b": 53},
      {"a": "G", "b": 19},
      {"a": "H", "b": 87},
      {"a": "I", "b": 52}
    ]
  },
  "transform": [
    {
      "window": [
        {"op": "first_value", "field": "b", "as": "b2"}
      ]
    },
    {"calculate": "datum.b / datum.b2", "as": "b3"}
  ],
  "mark": "bar",
  "encoding": {
    "x": {"field": "a", "type": "ordinal"},
    "y": {"field": "b3", "type": "quantitative"}
  }
}

```

---

<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: [November 11, 2019, 9:50am UTC](https://discuss.elastic.co/t/acessing-array-in-vega-lite/203357/3 "2019-11-11T09:50:05Z")

</div>

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