# 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:** 1\
**Showing post:** 2

<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

---

_[View the full topic](https://discuss.elastic.co/t/tsvb-calculation/288477)._
