# Sum Aggregation on present and last year

**URL:** <https://discuss.elastic.co/t/sum-aggregation-on-present-and-last-year/193176>\
**Category:** Kibana\
**Created:** [July 31, 2019, 4:22pm UTC](https://discuss.elastic.co/t/sum-aggregation-on-present-and-last-year/193176 "2019-07-31T16:22:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Venkata\_Naresh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/venkata_naresh/32/51355_2.png) [@Venkata\_Naresh](https://discuss.elastic.co/u/Venkata_Naresh)\
**Post date:** [July 31, 2019, 4:22pm UTC](https://discuss.elastic.co/t/sum-aggregation-on-present-and-last-year/193176/1 "2019-07-31T16:22:06Z")

</div>

I have a Kibana table which contains year wise sales data. Now I want to add a new column which should contain the sum of sales of selected month to current month in the previous year.

Ex: The table contains all the sales data of current year (2019) month wise. If the user select the month January as a month filter, in the last column of the table I want to show the sum of sales from Jan to July (current month) in the last year (2018)

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [August 22, 2019, 8:58pm UTC](https://discuss.elastic.co/t/sum-aggregation-on-present-and-last-year/193176/2 "2019-08-22T20:58:17Z")

</div>

One way to do this is with a Markdown table in TSVB. Each aggregation you add has an Offset parameter in the Data Options tab.

In the screenshot below I constructed the table in Markdown format

```auto
|Max Avg Ticket Price - Now|Max Avg Ticket Price - 1d ago|
|--|--|
|{{ max_avg_ticket_price_now.last.formatted }}|{{ max_avg_ticket_price_1_d_ago.last.formatted }}

```

 ![Screenshot_2019-08-22%20Kibana](https://us1.discourse-cdn.com/elastic/original/3X/c/1/c19384034ee60a3918f4663e94f5eebac7f7df9f.png)

---

<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 19, 2019, 9:03pm UTC](https://discuss.elastic.co/t/sum-aggregation-on-present-and-last-year/193176/3 "2019-09-19T21:03:12Z")

</div>

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