# Tsvb calculation

**URL:** <https://discuss.elastic.co/t/tsvb-calculation/288477>\
**Category:** Kibana\
**Created:** [November 5, 2021, 8:58am UTC](https://discuss.elastic.co/t/tsvb-calculation/288477 "2021-11-05T08:58:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paigekim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paigekim/32/91494_2.png) [@paigekim](https://discuss.elastic.co/u/paigekim)\
**Post date:** [November 5, 2021, 8:58am UTC](https://discuss.elastic.co/t/tsvb-calculation/288477/1 "2021-11-05T08:58:36Z")

</div>

Hello,

I have a question regards to tsvb calculation.

I would like to get an accumulated Break Even Point(BEP) by using tsvb and you could see the attachment how I calculated.

Currently, I divide accumulated revenue by accumulated cost in a percentage format. On these percentage values, I just would like to see the values that are over 100% only since I am looking for BEP. Is there any way that I can put a filter on top of the calculated value?

I am expecting to do something like this

```auto
 (params.rev / params.cost) > 100%

```

Thank you!

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/5/f529c51f8d3505a9de812fd53129e6cf0b849d93.png)

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [November 5, 2021, 10:47am UTC](https://discuss.elastic.co/t/tsvb-calculation/288477/2 "2021-11-05T10:47:40Z")

</div>

Hi @paigekim ,

I think you could hijack the `clamp` tinymath to do what you want ([here's a Lens example with Formula](https://discuss.elastic.co/t/visualize-library-pie-chart/286690/4))

You can set a high value for the `clamp` to be sure to never reach it (i.e. 1000000% =\> max = 10000) and write the following:

```auto
clamp( (params.rev / params.cost) - 1, 0, 10000)

```

Explanation:

- `(params.rev / params.cost) - 1` offset by 100% the computation
- `clamp( ..., 0, 10000)` keeps the result within 0 and 1000000 (0%-1000000%)
- because of the offset, any value below 100% will go negative and the `clamp` will rewrite it as 0%. Anything above 100% will be kept as is (as longs as it does not pass 1000000%) and will be shown

---

<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:** [December 3, 2021, 10:47am UTC](https://discuss.elastic.co/t/tsvb-calculation/288477/3 "2021-12-03T10:47:46Z")

</div>

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