# Timelion fraction offset

**URL:** <https://discuss.elastic.co/t/timelion-fraction-offset/241477>\
**Category:** Kibana\
**Tags:** timelion\
**Created:** [July 16, 2020, 2:11pm UTC](https://discuss.elastic.co/t/timelion-fraction-offset/241477 "2020-07-16T14:11:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hugo\_Pires](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hugo_pires/32/68069_2.png) [@Hugo\_Pires](https://discuss.elastic.co/u/Hugo_Pires)\
**Post date:** [July 16, 2020, 2:11pm UTC](https://discuss.elastic.co/t/timelion-fraction-offset/241477/1 "2020-07-16T14:11:33Z")

</div>

Hello

Is it possible to use timelion offset to compare the value of a metric, daily, at the same hour (from now, for instance)? My question is that we are not considering the complete day, but a fraction starting 0:00, everyday the same.

Thank you

Hugo

---

<div class="post-metadata">

**Author:** ![Hugo\_Pires](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hugo_pires/32/68069_2.png) [@Hugo\_Pires](https://discuss.elastic.co/u/Hugo_Pires)\
**Post date:** [July 21, 2020, 2:13pm UTC](https://discuss.elastic.co/t/timelion-fraction-offset/241477/2 "2020-07-21T14:13:12Z")

</div>

I guess this could be a good alternative on using ES SQL on time analysis.

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [July 21, 2020, 4:02pm UTC](https://discuss.elastic.co/t/timelion-fraction-offset/241477/3 "2020-07-21T16:02:19Z")

</div>

You should be able to do this by using a scripted field "hour of day" (I think it's part of the logs sample data set). Create your timelion vis as usually, then add a filter pill below the query bar limiting the "hour of day" field to a certain range.

---

<div class="post-metadata">

**Author:** ![Hugo\_Pires](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hugo_pires/32/68069_2.png) [@Hugo\_Pires](https://discuss.elastic.co/u/Hugo_Pires)\
**Post date:** [July 21, 2020, 4:06pm UTC](https://discuss.elastic.co/t/timelion-fraction-offset/241477/4 "2020-07-21T16:06:31Z")

</div>

Could it be dynamic? Something like limiting to "current hour"?

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [July 21, 2020, 4:10pm UTC](https://discuss.elastic.co/t/timelion-fraction-offset/241477/5 "2020-07-21T16:10:15Z")

</div>

Unfortunately not fully automated because you can't use `Date.now()` in scripted fields: [Scripted Fields Date Math](https://discuss.elastic.co/t/scripted-fields-date-math/158649)

You would have to change the range in the filter manually

---

<div class="post-metadata">

**Author:** ![Hugo\_Pires](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hugo_pires/32/68069_2.png) [@Hugo\_Pires](https://discuss.elastic.co/u/Hugo_Pires)\
**Post date:** [July 21, 2020, 4:33pm UTC](https://discuss.elastic.co/t/timelion-fraction-offset/241477/6 "2020-07-21T16:33:59Z")

</div>

I was trying timelion in alternative to ES SQL wich seems to me more dificult.  
I was using

```auto
SUM (IF(@timestamp = MAX(@timestamp), 1,0)

```

to count the documents from the last period selected (dynamically) on the timefilter. But ES SQL doesn't allow me to use an aggregation function (MAX) inside an IF.

---

<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:** [August 18, 2020, 4:34pm UTC](https://discuss.elastic.co/t/timelion-fraction-offset/241477/7 "2020-08-18T16:34:21Z")

</div>

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