# Vega/Kibana : Data table that makes calculcations between aggregations

**URL:** <https://discuss.elastic.co/t/vega-kibana-data-table-that-makes-calculcations-between-aggregations/234323>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [May 26, 2020, 12:07pm UTC](https://discuss.elastic.co/t/vega-kibana-data-table-that-makes-calculcations-between-aggregations/234323 "2020-05-26T12:07:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![elisavet](https://avatars.discourse-cdn.com/v4/letter/e/258eb7/32.png) [@elisavet](https://discuss.elastic.co/u/elisavet)\
**Post date:** [May 26, 2020, 12:07pm UTC](https://discuss.elastic.co/t/vega-kibana-data-table-that-makes-calculcations-between-aggregations/234323/1 "2020-05-26T12:07:08Z")

</div>

Hi!

I want to do a data table in kibana like the following:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/c/cc895f05d487e4262f81ca052c8337e0bea603f3.png)

That means, the 2 first columns are the sum of price and quantity and the 3rd column divides both sums to get a ratio. **Also I want this to be dynamic to changes in time range.**

As far as I've seen getting the ratio is not possible in kibana, but I've noticed that there is a plugin were you can create Vega-Lite graphs in kibana.

I am new both in Vega-Lite and in kibana, so is there an example of code that creates a data table?

Thank you!

---

<div class="post-metadata">

**Author:** ![myasonik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/myasonik/32/62369_2.png) [@myasonik](https://discuss.elastic.co/u/myasonik)\
**Post date:** [May 26, 2020, 6:33pm UTC](https://discuss.elastic.co/t/vega-kibana-data-table-that-makes-calculcations-between-aggregations/234323/2 "2020-05-26T18:33:54Z")

</div>

Visualizations within Kibana should respect whatever your time filter is all the time if that's what you mean. You can also keep your time filter to relative dates which will keep your time up-to-date if you're looking for something like a constant "last two weeks" window.

Any 3rd party plugins you pull-in to Kibana are free to do whatever they want though so no guarantees that they will continue to respect your time filters.

---

<div class="post-metadata">

**Author:** ![elisavet](https://avatars.discourse-cdn.com/v4/letter/e/258eb7/32.png) [@elisavet](https://discuss.elastic.co/u/elisavet)\
**Post date:** [May 27, 2020, 7:41am UTC](https://discuss.elastic.co/t/vega-kibana-data-table-that-makes-calculcations-between-aggregations/234323/3 "2020-05-27T07:41:48Z")

</div>

Hi! Thank you for your answer.

Do you know where can I find a code example of how to create a data table with Vega?  
From the Vega site I didn't find anything.

---

<div class="post-metadata">

**Author:** ![myasonik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/myasonik/32/62369_2.png) [@myasonik](https://discuss.elastic.co/u/myasonik)\
**Post date:** [May 27, 2020, 5:01pm UTC](https://discuss.elastic.co/t/vega-kibana-data-table-that-makes-calculcations-between-aggregations/234323/4 "2020-05-27T17:01:45Z")

</div>

Well, Vega's not super meant for purely textual tables so it won't be fun, but you could make it work by absolutely positioning text to a grid...

Here's an example: [https://vega.github.io/vega-lite/examples/layer\_text\_heatmap.html](https://vega.github.io/vega-lite/examples/layer_text_heatmap.html)

---

<div class="post-metadata">

**Author:** ![elisavet](https://avatars.discourse-cdn.com/v4/letter/e/258eb7/32.png) [@elisavet](https://discuss.elastic.co/u/elisavet)\
**Post date:** [May 28, 2020, 6:43am UTC](https://discuss.elastic.co/t/vega-kibana-data-table-that-makes-calculcations-between-aggregations/234323/5 "2020-05-28T06:43:20Z")

</div>

Ok! I will check it out!  
Thanks! 🙂

---

<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:** [June 25, 2020, 6:43am UTC](https://discuss.elastic.co/t/vega-kibana-data-table-that-makes-calculcations-between-aggregations/234323/6 "2020-06-25T06:43:28Z")

</div>

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