# Inter record functions in Kibana?

**URL:** <https://discuss.elastic.co/t/inter-record-functions-in-kibana/95580>\
**Category:** Kibana\
**Created:** [August 2, 2017, 4:54pm UTC](https://discuss.elastic.co/t/inter-record-functions-in-kibana/95580 "2017-08-02T16:54:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cristian](https://avatars.discourse-cdn.com/v4/letter/c/a698b9/32.png) [@Cristian](https://discuss.elastic.co/u/Cristian)\
**Post date:** [August 2, 2017, 4:54pm UTC](https://discuss.elastic.co/t/inter-record-functions-in-kibana/95580/1 "2017-08-02T16:54:45Z")

</div>

Hi All!  
I have forex information for each day. Close, Open, Low, High.  
Now, I would like to calculate the difference in % between a point in time, lets say today (t0), and the day before (-t1). That is: (|t0-t1|/((t0-t1)/2))\*100  
Are there any "inter record" functions to use for this in Kibana? How can I "fetch" a value from another row?  
I would like to display this data in a table per day. So each row would have the data for that date but also the calculated fields.

```
Desired result:
Date, Open, Close, High,Low, % Diff
2017-08-01, 10, 11, 13, 9, 10%
207-07-31, 9, 10, 12, 8, x%

```

Any suggestions?

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [August 2, 2017, 5:02pm UTC](https://discuss.elastic.co/t/inter-record-functions-in-kibana/95580/2 "2017-08-02T17:02:42Z")

</div>

I'm not sure of a way to get the percent difference, but you can use the "Derivative" aggregation to get the actual difference. So instead of what you suggested, it might look like the following:

```auto
Date, Open, Close, High,Low,Diff
2017-08-01, 10, 11, 13, 9, 4
207-07-31, 9, 10, 12, 8, x

```

---

<div class="post-metadata">

**Author:** ![Cristian](https://avatars.discourse-cdn.com/v4/letter/c/a698b9/32.png) [@Cristian](https://discuss.elastic.co/u/Cristian)\
**Post date:** [August 11, 2017, 1:37pm UTC](https://discuss.elastic.co/t/inter-record-functions-in-kibana/95580/3 "2017-08-11T13:37:07Z")

</div>

Thanks and sorry for late reply. Dont how the "derivative" works at all. Do you know an example somewhere that I can read? Dont really understand the manual ([https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-derivative-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-derivative-aggregation.html))

Br  
Cristian

---

<div class="post-metadata">

**Author:** ![Cristian](https://avatars.discourse-cdn.com/v4/letter/c/a698b9/32.png) [@Cristian](https://discuss.elastic.co/u/Cristian)\
**Post date:** [August 14, 2017, 9:30am UTC](https://discuss.elastic.co/t/inter-record-functions-in-kibana/95580/4 "2017-08-14T09:30:24Z")

</div>

Any other suggestion how to solve this?

---

<div class="post-metadata">

**Author:** ![Cristian](https://avatars.discourse-cdn.com/v4/letter/c/a698b9/32.png) [@Cristian](https://discuss.elastic.co/u/Cristian)\
**Post date:** [August 28, 2017, 11:39am UTC](https://discuss.elastic.co/t/inter-record-functions-in-kibana/95580/5 "2017-08-28T11:39:14Z")

</div>

Is this possible to do in Logstash? when reading the new info is it possible to fetch data from the index and do the calculations?

---

<div class="post-metadata">

**Author:** ![Cristian](https://avatars.discourse-cdn.com/v4/letter/c/a698b9/32.png) [@Cristian](https://discuss.elastic.co/u/Cristian)\
**Post date:** [August 29, 2017, 2:24pm UTC](https://discuss.elastic.co/t/inter-record-functions-in-kibana/95580/6 "2017-08-29T14:24:31Z")

</div>

Ok. So I tried the Derivative function but this gives me only the difference to the row before. A better aggregation is "Serial Differencing"-aggregation where I can pin point the row that should be used in the difference. Much better. I still have a problem though. I would like to create my own calculation based on that difference. Is this possible? I would like create a Metric that uses two other metrics ( the serial difference and a sum) as input.

Also, I would like calculate the difference between different fields. The "Serial Differencing agg" calculates on one field. Is it possible to calculate the serial diff between lets say "High"-value today and "Open"-value 3 rows ago?  
Br  
Cristian

---

<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 26, 2017, 2:24pm UTC](https://discuss.elastic.co/t/inter-record-functions-in-kibana/95580/7 "2017-09-26T14:24:32Z")

</div>

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