# Serial Diff two metrics

**URL:** https://discuss.elastic.co/t/serial-diff-two-metrics/244978
**Category:** Kibana
**Created:** [August 14, 2020, 8:59am UTC](https://discuss.elastic.co/t/serial-diff-two-metrics/244978 "2020-08-14T08:59:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Shyrine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shyrine/32/73833_2.png) [@Shyrine](https://discuss.elastic.co/u/Shyrine)
#### Post date: [August 14, 2020, 8:59am UTC](https://discuss.elastic.co/t/serial-diff-two-metrics/244978/1 "2020-08-14T08:59:44Z")

</div>

Hi,

I am wondering if it is possible to have a serial diff in aggregation between two metrics.... ??

What I am trying to do is having an other bar or line, calculating the difference between the two bars (green and orange).

 ![Capture](https://us1.discourse-cdn.com/elastic/original/3X/4/b/4ba5e7b826b20ac31a2ac3f48c553e9d72586336.png)

Thanks

---

<div class="post-metadata">

### Author: ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)
#### Post date: [August 14, 2020, 12:53pm UTC](https://discuss.elastic.co/t/serial-diff-two-metrics/244978/2 "2020-08-14T12:53:34Z")

</div>

Hi @Shyrine,

you can do it in TSVB, let me know if it works for you, here's the example with metrics 'sum':

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

---

<div class="post-metadata">

### Author: ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)
#### Post date: [August 14, 2020, 2:38pm UTC](https://discuss.elastic.co/t/serial-diff-two-metrics/244978/3 "2020-08-14T14:38:42Z")

</div>

@Shyrine, I just thought about solution that would allow you to use the vertical bar visualization - create a scripted field that calculates the difference between these two and add it to your chart. Here's the tutorial on it: [https://www.elastic.co/blog/using-painless-kibana-scripted-fields](https://www.elastic.co/blog/using-painless-kibana-scripted-fields)  
In your case it would be something like: `doc['fieldName1'].value - doc['fieldName2'].value`

---

<div class="post-metadata">

### Author: ![Shyrine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shyrine/32/73833_2.png) [@Shyrine](https://discuss.elastic.co/u/Shyrine)
#### Post date: [August 14, 2020, 2:53pm UTC](https://discuss.elastic.co/t/serial-diff-two-metrics/244978/4 "2020-08-14T14:53:39Z")

</div>

Hi @Marta_Bondyra,

Thank you for your response, I will try to do that in TSVB but i need to take my time to figure out how it works 🤨

However, I already thought about creating a scripted field (that was my first idea) but my superior told me that i have to avoid scripted field because it would take a lot of space...

Thank you agin. I will share my graph once done with it in TSVB !

---

<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: [September 11, 2020, 2:53pm UTC](https://discuss.elastic.co/t/serial-diff-two-metrics/244978/5 "2020-09-11T14:53:40Z")

</div>

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