# In Timelion, how do I reference the current value that my "if" statement is working on so that I can use that value in my "then" statement?

**URL:** <https://discuss.elastic.co/t/in-timelion-how-do-i-reference-the-current-value-that-my-if-statement-is-working-on-so-that-i-can-use-that-value-in-my-then-statement/183595>\
**Category:** Kibana\
**Created:** [May 30, 2019, 6:49pm UTC](https://discuss.elastic.co/t/in-timelion-how-do-i-reference-the-current-value-that-my-if-statement-is-working-on-so-that-i-can-use-that-value-in-my-then-statement/183595 "2019-05-30T18:49:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![waverly360](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waverly360/32/47180_2.png) [@waverly360](https://discuss.elastic.co/u/waverly360)\
**Post date:** [May 30, 2019, 6:49pm UTC](https://discuss.elastic.co/t/in-timelion-how-do-i-reference-the-current-value-that-my-if-statement-is-working-on-so-that-i-can-use-that-value-in-my-then-statement/183595/1 "2019-05-30T18:49:02Z")

</div>

`.es(index="metricbeat-*",q="beat.hostname:srvwin01", metric="max:system.network.in.bytes", kibana=true,split=system.network.name:64).fit(scale).scale_interval(1s).derivative().if(lt,0,0).divide(1048576).lines(fill=2, width=1).multiply(8).trim(start=1,end=1).label(regex='.* system.network.name:(.*) >.*', label="Inbound $1")`

Above is the query I'm using to report on metricbeat data to determine bandwidth utilization, but since the Windows byte counter resets after it hits 4GB, I had to add the "if(lt,0,0)" to zero out the derivative anytime it goes negative. What I'd _rather_ do is some form of addition to try and compensate anytime the derivative goes negative, but I don't know how to reference the _current_ value in the dataset that the if statement is working on. (i.e. if the value is -278987942, then return -278987942 plus 4000000000 (and yes I'm aware that math isn't accurate..just needed an example))

---

<div class="post-metadata">

**Author:** ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)\
**Post date:** [May 30, 2019, 10:17pm UTC](https://discuss.elastic.co/t/in-timelion-how-do-i-reference-the-current-value-that-my-if-statement-is-working-on-so-that-i-can-use-that-value-in-my-then-statement/183595/2 "2019-05-30T22:17:16Z")

</div>

The "then" clause can accept a series. It's a bit verbose, but you should be able to duplicate your original series in the "then" clause and add the additional math statements you need. Here's an example of a series in the then clause in the docs: [https://www.elastic.co/guide/en/kibana/current/timelion-conditional.html](https://www.elastic.co/guide/en/kibana/current/timelion-conditional.html)

---

<div class="post-metadata">

**Author:** ![waverly360](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waverly360/32/47180_2.png) [@waverly360](https://discuss.elastic.co/u/waverly360)\
**Post date:** [May 30, 2019, 10:18pm UTC](https://discuss.elastic.co/t/in-timelion-how-do-i-reference-the-current-value-that-my-if-statement-is-working-on-so-that-i-can-use-that-value-in-my-then-statement/183595/3 "2019-05-30T22:18:38Z")

</div>

For whatever reason, I have not been able to duplicate my exact clause..and I suspect it's because I'm using a split in the original one. When I've tried to do it, my graph blows up.

---

<div class="post-metadata">

**Author:** ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)\
**Post date:** [May 30, 2019, 10:20pm UTC](https://discuss.elastic.co/t/in-timelion-how-do-i-reference-the-current-value-that-my-if-statement-is-working-on-so-that-i-can-use-that-value-in-my-then-statement/183595/4 "2019-05-30T22:20:17Z")

</div>

In that case I would open a ticket on the Kibana [github repo](https://github.com/elastic/kibana/issues/new?template=Bug_report.md)

---

<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 27, 2019, 10:20pm UTC](https://discuss.elastic.co/t/in-timelion-how-do-i-reference-the-current-value-that-my-if-statement-is-working-on-so-that-i-can-use-that-value-in-my-then-statement/183595/5 "2019-06-27T22:20:26Z")

</div>

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