# Show bar horizontal as percentage

**URL:** <https://discuss.elastic.co/t/show-bar-horizontal-as-percentage/320752>\
**Category:** Kibana\
**Tags:** runtime-fields\
**Created:** [December 8, 2022, 7:18am UTC](https://discuss.elastic.co/t/show-bar-horizontal-as-percentage/320752 "2022-12-08T07:18:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikhatanu](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@mikhatanu](https://discuss.elastic.co/u/mikhatanu)\
**Post date:** [December 8, 2022, 7:18am UTC](https://discuss.elastic.co/t/show-bar-horizontal-as-percentage/320752/1 "2022-12-08T07:18:26Z")

</div>

Hello, i have this bar horizontal lens:

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

I wanted to show the numbers of volume\_total (5,797,557) as percentage (the application\_name's volume\_total divided by the sum of volume\_total of all application). But if i use bar horizontal percentage, all shows as 100%:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/c/2cf6d94f8d8dbf11c672c6ddeeb58ff8e0643708.png)

for more context, volume\_total is a field which value is from index template's runtime field of adding 2 other field (volume\_in and volume\_out). my example log:

> name, volume\_in, volume\_out, volume\_total (runtime field)  
> abc,10,20,30  
> def,20,30,50  
> ghi,15,15,30

---

<div class="post-metadata">

**Author:** ![nickofthyme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickofthyme/32/60032_2.png) [@nickofthyme](https://discuss.elastic.co/u/nickofthyme)\
**Post date:** [December 8, 2022, 9:36pm UTC](https://discuss.elastic.co/t/show-bar-horizontal-as-percentage/320752/2 "2022-12-08T21:36:52Z")

</div>

Hey @mikhatanu 👋,

I'm not sure I understand what you want but I hope some context would help you get there.

First of all, the **Bar horizontal percentage** visualization type computes the percentages based on the values within the given buckets. As your first image shows, you only have one value in each bucket, the buckets defined as _ **Top 10 values of application\_name** _. Thus each value within the three separate buckets is 100% of the bucket size.

Secondly, I think the solution for you would be to use a lens [`formula`](https://www.elastic.co/guide/en/kibana/current/lens.html#lens-formulas) with the `overall_sum` function, see _ **Percent of total example** _ example in the [docs](https://www.elastic.co/guide/en/kibana/8.5/lens.html#lens-formulas).

This function is defined in greater detail in the **Formula reference** docs in Lens, see docs reference below...

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

With this function you are able to determine cumulative sums across all series, then equate the series to a percentage of the total. This formula would look something like...

```sh
sum(volume_total) / overall_sum(sum(volume_total))

```

> Note: you can set the **Value format** of the resulting value from the formula in the popout as a **Percent** type.

Then using the **Bar horizontal stacked** visualization type you would have a resulting visualization like this...

![Screen Recording 2022-12-08 at 02.26.21 PM](https://us1.discourse-cdn.com/elastic/original/3X/b/7/b790bfc28c852c39dd9a9095d43f5d1798151919.gif)

Hope that helps.

---

<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:** [January 5, 2023, 9:37pm UTC](https://discuss.elastic.co/t/show-bar-horizontal-as-percentage/320752/3 "2023-01-05T21:37:12Z")

</div>

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