# How to calculate a month's projection in a TSVB's math field

**URL:** <https://discuss.elastic.co/t/how-to-calculate-a-months-projection-in-a-tsvbs-math-field/355732>\
**Category:** Kibana\
**Tags:** visualisation\
**Created:** [March 19, 2024, 2:18pm UTC](https://discuss.elastic.co/t/how-to-calculate-a-months-projection-in-a-tsvbs-math-field/355732 "2024-03-19T14:18:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jalil\_Sayarh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jalil_sayarh/32/122075_2.png) [@Jalil\_Sayarh](https://discuss.elastic.co/u/Jalil_Sayarh)\
**Post date:** [March 19, 2024, 2:18pm UTC](https://discuss.elastic.co/t/how-to-calculate-a-months-projection-in-a-tsvbs-math-field/355732/1 "2024-03-19T14:18:44Z")

</div>

I want to use TSVB's math field to have a simple projection of one variable's data to have a projection of that variable over to the month. but I can't seem to figure it out, I tried using timestamp like this :

```auto
31-((params._timestamp - params._all.a.timestamps[0]) / 86400000)

```

It worked to pull the number of days that have passed and the number of days that are left in the month to average it using the number of days and bring it back to the month value but it doesn't seem to work.

The expression works when I'm on last time range mode but not on entire time range, and the variable's sum has to be for the entire time range for this simple forecast to work.

So the idea would be just to take the daily average of the entire timerange and bring it to a monthly forecast like this :

```auto
params.a/((params._timestamp - params._all.a.timestamps[0]) / 86400000)*31

```

Am I doing something wrong, or is there another expression that could be more efficient in this example ?

---

<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:** [April 16, 2024, 2:18pm UTC](https://discuss.elastic.co/t/how-to-calculate-a-months-projection-in-a-tsvbs-math-field/355732/2 "2024-04-16T14:18:48Z")

</div>

Closed on April 16, 2024, 2:18pm UTC

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