# Issue transforming data for Vega visualization

**URL:** <https://discuss.elastic.co/t/issue-transforming-data-for-vega-visualization/299669>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [March 14, 2022, 9:18pm UTC](https://discuss.elastic.co/t/issue-transforming-data-for-vega-visualization/299669 "2022-03-14T21:18:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaigbdb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaigbdb/32/74219_2.png) [@shaigbdb](https://discuss.elastic.co/u/shaigbdb)\
**Post date:** [March 14, 2022, 9:18pm UTC](https://discuss.elastic.co/t/issue-transforming-data-for-vega-visualization/299669/1 "2022-03-14T21:18:46Z")

</div>

I have the following response:

```auto
aggregations" : {
  "a" : {...},
  "b" : {...},
  "c" : {...},
  "d" : {
    "value" : 5
  },
  "e" : {
    "value" : 6
  },
  "f" : {
    "value" : 7
  }
}

```

d, e and f are sum\_bucket aggregations on a,b, and c respectively.  
I need to transform it into a format that can be parsed by Vega's encoding block - specifically, Vega should display d,e, and f on one axis, with the respective values on the other axis.

I was unable to use transform to manipulate the data. I've tried several different syntaxes, but looking at the debugger either I got an error trying to retrieve the data or the data returned the same as before despite going through a transformation. I'm not even entirely sure which transformation would work for this scenario (though I suspect i need to use calculate).

Thanks,  
Shai

---

<div class="post-metadata">

**Author:** ![drewdaemon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drewdaemon/32/97779_2.png) [@drewdaemon](https://discuss.elastic.co/u/drewdaemon)\
**Post date:** [March 15, 2022, 9:40pm UTC](https://discuss.elastic.co/t/issue-transforming-data-for-vega-visualization/299669/2 "2022-03-15T21:40:54Z")

</div>

Hi Shai,

This one had me scratching my head, too. I think you can accomplish what you're describing by way of the [Vega-Lite "fold" transform](https://vega.github.io/vega-lite/docs/fold.html).

Here's a [working example](https://vega.github.io/editor/#/url/vega-lite/N4IgJAzgxgFgpgWwIYgFwhgF0wBwqgegIDc4BzJAOjIEtMYBXAI0poHsDp5kTykBaADZ04JAKyUAVhDYA7EABoQmOoLhoQAUQAeSBDjUACAEJIAToYDCMc5kMAxM2wSGAynDVQ7AQTJkIiiAAJkiYKKigxEiCDHABESBIfmZ8KnLxoOGR0bFoAEwAvkpMaNkx6qgAzEUgUKUgUeVoACw1QfWNuahiNRVlXQBsNQBmHTkVAOwF00rDbGbImPU4TjhwZpgAnhpJZCkUabIBM8pmSEdzC2gA2qBzgu2o18GB6rMgALoFH0rIZgDWGiY5lesigbCCNFkZHq2nqwxoHkeIH+cG2Si2aw0smcUOigSQ2hoGWUqgqIAgDAQAH0mAwoKifMlUux5CdtgkEUiNJ04JReYFMeSAI4Mc4qMIqUgEokkiVqDQANXGIGm0yAA).

Let me know if I got this right!

---

<div class="post-metadata">

**Author:** ![shaigbdb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaigbdb/32/74219_2.png) [@shaigbdb](https://discuss.elastic.co/u/shaigbdb)\
**Post date:** [March 17, 2022, 5:22pm UTC](https://discuss.elastic.co/t/issue-transforming-data-for-vega-visualization/299669/3 "2022-03-17T17:22:46Z")

</div>

That was it!  
Thanks Andrew!

---

<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:** [April 14, 2022, 5:23pm UTC](https://discuss.elastic.co/t/issue-transforming-data-for-vega-visualization/299669/4 "2022-04-14T17:23:05Z")

</div>

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