# Aggregate diff video views

**URL:** <https://discuss.elastic.co/t/aggregate-diff-video-views/128226>\
**Category:** Elasticsearch\
**Created:** [April 16, 2018, 3:48pm UTC](https://discuss.elastic.co/t/aggregate-diff-video-views/128226 "2018-04-16T15:48:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![himberjack](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/himberjack/32/48211_2.png) [@himberjack](https://discuss.elastic.co/u/himberjack)\
**Post date:** [April 16, 2018, 3:48pm UTC](https://discuss.elastic.co/t/aggregate-diff-video-views/128226/1 "2018-04-16T15:48:32Z")

</div>

Hi,

We have created an index that saves timestamp, entry\_id & video views.  
We sample the video view from a website, and saves it as is into the ES (that is, the current views value, not the diff).

Now, we want to tell how many video views we had in specific entries, daily, in the last 30 days. so what we do is that we sum all maxes per day per entry and substract sum of all minimums, per day.  
Problem is, that we don't really know what was before the last 30 days, so we cannot rely on an entry showing 1000 views while it may have 800 in day 31 (outside our window), causing us to sum 1000 views and not 200.

What is the best approach to calculate this?

Many thanks

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 16, 2018, 7:07pm UTC](https://discuss.elastic.co/t/aggregate-diff-video-views/128226/2 "2018-04-16T19:07:56Z")

</div>

Could you provide a clear example of what data you have and what you are trying to calculate?

---

<div class="post-metadata">

**Author:** ![himberjack](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/himberjack/32/48211_2.png) [@himberjack](https://discuss.elastic.co/u/himberjack)\
**Post date:** [April 25, 2018, 2:51pm UTC](https://discuss.elastic.co/t/aggregate-diff-video-views/128226/3 "2018-04-25T14:51:47Z")

</div>

I want to show daily video views. But I am not inserting relative views to the ES, but growing metrics..

---

<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:** [May 23, 2018, 2:51pm UTC](https://discuss.elastic.co/t/aggregate-diff-video-views/128226/4 "2018-05-23T14:51:51Z")

</div>

Closed on May 23, 2018, 2:51pm UTC

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