# Visualize Library - Pie chart

**URL:** <https://discuss.elastic.co/t/visualize-library-pie-chart/286690>\
**Category:** Kibana\
**Created:** [October 14, 2021, 8:07am UTC](https://discuss.elastic.co/t/visualize-library-pie-chart/286690 "2021-10-14T08:07:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emin\_Cevikol](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emin_cevikol/32/91199_2.png) [@Emin\_Cevikol](https://discuss.elastic.co/u/Emin_Cevikol)\
**Post date:** [October 14, 2021, 8:07am UTC](https://discuss.elastic.co/t/visualize-library-pie-chart/286690/1 "2021-10-14T08:07:23Z")

</div>

Hi everyone,

I have a pie chart which shows percentage of two values (Success or Failure) count. I want to filter for example If sum of count greater then 1000, Then show me the pie chart otherwise not. How can I provide that?

The problem is, For example 5 request failing and 5 request success, It gives me %50 success percentage. But thats not problem for us and I do not want to see pie chart If total count size less then 1000

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/6/66159283e509aba664140f65c4e9bb7f8af17746.png)

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

Thanks,

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [October 14, 2021, 1:58pm UTC](https://discuss.elastic.co/t/visualize-library-pie-chart/286690/2 "2021-10-14T13:58:21Z")

</div>

I don't think there is a mechanism to conditionally show visualizations in Kibana. Maybe you can achieve that with Vega and its [`condition` property](https://vega.github.io/vega-lite/docs/condition.html), but I'm not that proficient in the component, so there's a chance I'm not right, sorry.

Also, feel free to create a Feature Request in the Kibana tracker with as much detail as possible on your use case.

---

<div class="post-metadata">

**Author:** ![ghudgins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ghudgins/32/138532_2.png) [@ghudgins](https://discuss.elastic.co/u/ghudgins)\
**Post date:** [October 14, 2021, 2:38pm UTC](https://discuss.elastic.co/t/visualize-library-pie-chart/286690/3 "2021-10-14T14:38:06Z")

</div>

we have this enhancement here - It sounds similar so i'll put a reference to this post [[Lens] Allow client-side bucket filtering of numbers by selecting the visible number range · Issue #86190 · elastic/kibana · GitHub](https://github.com/elastic/kibana/issues/86190)

---

<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:** [October 14, 2021, 3:53pm UTC](https://discuss.elastic.co/t/visualize-library-pie-chart/286690/4 "2021-10-14T15:53:03Z")

</div>

I think in Lens it may be possible to do something.

Maybe this is a long stretch of the `Lens Formula` feature, while waiting [for the conditionals support](https://github.com/elastic/kibana/issues/94603) in it, you can model the problem this way:

` ifOverThousandOutputOne( overall_sum(count()) ) * overall_sum(count())`

The `ifOverThousandOutputOne` is an hypothetical function we can model this way:

- if the `overall_sum(count())` minus X (in your case 1000) is above 0 output 1
- otherwise output 0

One way to model this hypothetical function is to use the `clamp` math function:

```auto
clamp( overall_sum(count()) - 1000, 0, 1)

```

The `clamp` function will return a value between 0 or 1 in this case, but what it is used here is to return 0 for all those values below 1000 ( 5 - 1000 = -995 which be clamped to `0`). If you have values between 0 and 1 there are still some tricks available, but if you working with `count()` do not worry that they are all integers.

At this point the full formula can be:

```auto
clamp( overall_sum(count()) - 1000, 0, 1) * overall_sum(count())

```

Some examples here for `overall_sum(count())` as 5 and 2000:

```auto
clamp((5 - 1000), 0, 1) * 5 => 0
clamp((2000 - 1000), 0, 1) * 2000 => 2000

```

Of course you can replace `overall_sum(count())` with any other function you like.

The resulting chart will be a little bit misleading in case of \<1000, but a good title may mitigate that - as all slices will have a 0 size:

 ![Screenshot 2021-10-14 at 17.49.58](https://us1.discourse-cdn.com/elastic/original/3X/3/2/32437cb68b9561310f412d53d40aeeb9b8104193.png)

Would that help?

---

<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:** [November 11, 2021, 3:53pm UTC](https://discuss.elastic.co/t/visualize-library-pie-chart/286690/5 "2021-11-11T15:53:40Z")

</div>

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