# Kibana visualization

**URL:** <https://discuss.elastic.co/t/kibana-visualization/333217>\
**Category:** Kibana\
**Tags:** visualisation\
**Created:** [May 11, 2023, 2:37pm UTC](https://discuss.elastic.co/t/kibana-visualization/333217 "2023-05-11T14:37:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sai\_ravi\_shankar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sai_ravi_shankar/32/120767_2.png) [@sai\_ravi\_shankar](https://discuss.elastic.co/u/sai_ravi_shankar)\
**Post date:** [May 11, 2023, 2:37pm UTC](https://discuss.elastic.co/t/kibana-visualization/333217/1 "2023-05-11T14:37:18Z")

</div>

Hi

I am trying to build a visualization. Here is the scenario.

i have two coulmns, lets say company\_name and cost\_paid\_by\_company. i need to show the cost\_paid\_by\_company which is higher and lower than the threshold in any kind of visualization

Data:  
company\_name | cost\_paid\_by\_company  
A | 120  
B | 100  
A | 50  
C | 70  
C | 20

Sorting with sum\_cost\_paid\_by\_company:

company\_name | sum\_cost\_paid\_by\_company  
A | 170  
B | 100  
C | 90

Now threshold is 95

Company's with higher than thresold = 66.6%  
Company's with lower than thresold = 33.3%

How can i represent this in any kind of visualization for Company's with higher than thresold and Company's with lower than thresold ?

---

<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:** [May 12, 2023, 7:48am UTC](https://discuss.elastic.co/t/kibana-visualization/333217/2 "2023-05-12T07:48:38Z")

</div>

Hi @sai_ravi_shankar

I think you can visualize the final percentage using Lens formula to compute your values:

- Create a Percentage chart (either horizontal or vertical)
- Define a `Top values of company_name` as Breakdown by dimension, and apply the `Collapse by Sum` to it
- Then define two Metric dimensions as follow:
  - First formula would be: `ifelse(sum(cost_paid_by_company) > 95, 1, 0) / overall_sum(ifelse(sum(cost_paid_by_company) > 0, 1, 0))` and label it `Companies higher than threshold`
  - Next a similar formula but for companies with lower cost: `ifelse(sum(cost_paid_by_company) <= 95, 1, 0) / overall_sum(ifelse(sum(cost_paid_by_company) > 0, 1, 0))` and label it `Companies lower than threshold`

To explain a bit the formula, I'll break it down in two pieces:

- First part is counting the companies who paid more than the threshold

```auto
ifelse(sum(cost_paid_by_company) > 95, 1, 0) 

```

- And this will be divided by the sum of all the companies who had any cost paid (\>0):

```auto
overall_sum(ifelse(sum(cost_paid_by_company) > 0, 1, 0))

```

Note that the `overall_sum` will compute the sum beyond the `Breakdown by` and count all the companies, hence the final percentage ratio.

Here's an example I built who the Ecommerce sample dataset. I used `category.keyword` (as your company\_name) and `sum(products.base_price)` (as your `sum(cost_paid...)`) with a threshold of $3000:

 ![Screenshot 2023-05-12 at 09.37.18](https://us1.discourse-cdn.com/elastic/original/3X/8/4/8496db86dc8bbd167c3817fd79d04816c481f125.png)

If what you want instead is know which company passed the threshold and which not, maybe a table can be helpful with some custom coloring:

 ![Screenshot 2023-05-12 at 09.16.43](https://us1.discourse-cdn.com/elastic/original/3X/a/9/a9b88039bbbe7a6c97a765849ce3fd0a48e04443.jpeg)

---

<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:** [June 9, 2023, 7:49am UTC](https://discuss.elastic.co/t/kibana-visualization/333217/3 "2023-06-09T07:49:12Z")

</div>

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