# Showing values in a graphic bar

**URL:** <https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025>\
**Category:** Kibana\
**Tags:** visualisation\
**Created:** [June 7, 2024, 10:34am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025 "2024-06-07T10:34:01Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![juandres117](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@juandres117](https://discuss.elastic.co/u/juandres117)\
**Post date:** [June 7, 2024, 10:34am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/1 "2024-06-07T10:34:01Z")

</div>

Hi! I'm really new to Kibana and Elasticsearch, but I'm trying to visualize data in a specific way that might be difficult.

I'm trying to set up two things:

1. I want to establish a threshold. For example, if any column has a value less than or equal to 2, I want it to be red.
2. I want to place the name of the label near the column, just to clarify what the label is so I don't have to check the legend constantly.

Is this possible?? Thank you for reading!!

 ![Captura desde 2024-06-07 12-29-24](https://us1.discourse-cdn.com/elastic/original/3X/5/1/5140d0f73230e0d8a6029d84c6103b5cf9521702.png)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 7, 2024, 12:26pm UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/2 "2024-06-07T12:26:42Z")

</div>

Welcome!

Well, you could do very mad things with Kibana Lens nowadays, thanks to the awesome Kibana teams...

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/9/89e4a259d5cec5ffea2bb21922a9c9f96e9e222d.png)

Using Formulas instead of Quick Functions:

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

For example, the "pink" part of the bar has the following formula:

```auto
(
    average(marketing.cars) - 
    overall_average(average(marketing.cars))
) 
    *
(
    clamp(
        average(marketing.cars) - 
        overall_average(average(marketing.cars)), 0, 1)
)

```

And the green part has:

```auto
average(marketing.cars) - 
(
  clamp(
    average(marketing.cars) - overall_average(average(marketing.cars)),0,1)*(average(marketing.cars)
   -overall_average(average(marketing.cars))))

```

Hard to understand may be but that could give you some ideas on how to build what you need.

---

<div class="post-metadata">

**Author:** ![juandres117](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@juandres117](https://discuss.elastic.co/u/juandres117)\
**Post date:** [June 10, 2024, 6:54am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/3 "2024-06-10T06:54:44Z")

</div>

Thank you for your answer! I didn't know I can make all of these in Kibana. However, I think that my question is more specific about visualization. I really dont know how I can make a column change depending on its value.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 10, 2024, 9:09am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/4 "2024-06-10T09:09:40Z")

</div>

> [@juandres117](#):
>
> I really dont know how I can make a column change depending on its value.

Could you clarify with an example? Is that the same need as expressed before:

> I want to establish a threshold. For example, if any column has a value less than or equal to 2, I want it to be red.

If so, I think I answered with a solution.

---

<div class="post-metadata">

**Author:** ![juandres117](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@juandres117](https://discuss.elastic.co/u/juandres117)\
**Post date:** [June 10, 2024, 10:45am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/5 "2024-06-10T10:45:32Z")

</div>

I mean, I might be not understanding what you've said. I have some columns, each of them is a value, not depending on anything. The values I'm working with are like that. So now, what I want is to color that specific column depending on that value.

In the example that you have provided, you have a the number of cars pero year, so it's simple because you have the same data and you can do what you are saying.

I'm not sure if I can do what I'm trying to explain.

Thank you a lot and sorry for the problems

---

<div class="post-metadata">

**Author:** ![juandres117](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@juandres117](https://discuss.elastic.co/u/juandres117)\
**Post date:** [June 10, 2024, 10:46am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/6 "2024-06-10T10:46:26Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/5/3/536aeba81ac9ab54d96462607ab83f355c0153c5.png)  
These are my columns.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 10, 2024, 11:44am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/7 "2024-06-10T11:44:55Z")

</div>

Indeed. As you don't have a X axis, I don't think my solution is possible.

And I don't see how you can do it with Lens. So my guess is that the only workaround is by using [Vega](https://www.elastic.co/guide/en/kibana/current/vega.html).

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

It's a bit harder as it requires some code but you can do almost [whatever you want](https://vega.github.io/vega-lite/examples/#bar-charts) with it.

---

<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:** [June 10, 2024, 12:05pm UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/8 "2024-06-10T12:05:34Z")

</div>

It is technically possible to do so, leveraging Lens formula, similar to the way @dadoonet showed before.  
But I would recommend 1 metric per chart probably there:

 ![Screenshot 2024-06-10 at 14.00.46](https://us1.discourse-cdn.com/elastic/original/3X/1/9/1953fdef3056d961ff073eff76df0a0aa3b1d462.png)

What I've done here is basically define 2 formulas based on a threshold of 1000:

- `Above 1000`: is a formula that sets any value above 1000 to its value, or 0 otherwise =\> `ifelse( average(value) >= 1000, average(value), 0)`
- `Below 1000`: is the same formula but the 2nd and 3rd arguments swapped: `ifelse( average(value) >= 1000, 0, average(value))`

Then you can set the color per metric as I did in the picture above.  
Choosing a stacked vertical bar would make the trick (as `0` int he `ifelse` would work as a filter between the two metrics).  
Of course you could define 2 formulas per metric, but it would be not super manageable.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 10, 2024, 12:23pm UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/9 "2024-06-10T12:23:29Z")

</div>

I guess this works because you have here a X axis... Which is not I think what @juandres117 has in this dataset... :😉

---

<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:** [June 10, 2024, 1:41pm UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/10 "2024-06-10T13:41:54Z")

</div>

The concept is still there. Just need to create a layer per metric type and reproduce the same logic

---

<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:** [June 10, 2024, 1:52pm UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/11 "2024-06-10T13:52:45Z")

</div>

To explain:

- for each layer define a `Filter` defined as `*` with the label of the metric
- define the 2 formulas for the given metric

This way the horizontal axis is "simulated" and the trick would work.

 ![Screenshot 2024-06-10 at 15.51.33](https://us1.discourse-cdn.com/elastic/original/3X/1/9/190858fa5a582a07502e4711cb7655c382a559b9.png)

The only problem would be the legend, which will contain duplicates, but I've hidden it for now.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 10, 2024, 9:42pm UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/12 "2024-06-10T21:42:55Z")

</div>

> [@Marco\_Liberati](#):
>
> This way the horizontal axis is "simulated" and the trick would work.

Ha! That's smart! 😊

---

<div class="post-metadata">

**Author:** ![juandres117](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@juandres117](https://discuss.elastic.co/u/juandres117)\
**Post date:** [June 11, 2024, 7:19am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/13 "2024-06-11T07:19:02Z")

</div>

Thanks everyone for the answer I think that I've already got it. However, and last question, do you have a good Vega tutorial there?

---

<div class="post-metadata">

**Author:** ![juandres117](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@juandres117](https://discuss.elastic.co/u/juandres117)\
**Post date:** [June 11, 2024, 7:31am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/14 "2024-06-11T07:31:20Z")

</div>

I have to be sure, so sorry to bother. What do yo mean by a filter defined as \*?

---

<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:** [June 11, 2024, 7:44am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/15 "2024-06-11T07:44:01Z")

</div>

Here's a Lens filter as horizontal axis value:

 ![Screenshot 2024-06-11 at 09.42.46](https://us1.discourse-cdn.com/elastic/original/3X/5/7/57ef4406d270e05ba7399a181b6540cb9bcdc56e.png)

In your case a Filter is just a way to simulate an axis, so defining it as `*` (match all) works fine as long as a custom label is used for each layer.

---

<div class="post-metadata">

**Author:** ![juandres117](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@juandres117](https://discuss.elastic.co/u/juandres117)\
**Post date:** [June 11, 2024, 7:56am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/16 "2024-06-11T07:56:53Z")

</div>

Doing like that and putting the formula that you explained me:

ifelse( average(activism.rateValue) \>= 1, average(activism.rateValue), 0)

I'm getting an error saying that:  
The Formula ifelse( average(activism.rateValue) \>= 1, average(activism.rateValue), 0) cannot be parsed

Do you know this?

---

<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:** [June 11, 2024, 8:28am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/17 "2024-06-11T08:28:22Z")

</div>

It looks like you are on an older version of the stack.  
What's the version of Es/Kibana?

The `ifelse` has been introduced in version 8.6.0.

---

<div class="post-metadata">

**Author:** ![juandres117](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@juandres117](https://discuss.elastic.co/u/juandres117)\
**Post date:** [June 11, 2024, 8:39am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/18 "2024-06-11T08:39:04Z")

</div>

There it is, kibana is in 8.4.3. I should change the version to do this? Or is anyway of getting it done here?

---

<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:** [June 11, 2024, 8:50am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/19 "2024-06-11T08:50:45Z")

</div>

Without `ifelse` you can approximate a boolean evaluation behaviour with `clamp` as @dadoonet wrote earlier on.  
But it's hard to grasp, and upgrading would bring more nice features in general.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 11, 2024, 9:36am UTC](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025/20 "2024-06-11T09:36:15Z")

</div>

> [@Marco\_Liberati](#):
>
> But it's hard to grasp, and upgrading would bring more nice features in general.

And also upgrading will help you to get all the security patches that has been added in the meantime.

[Next page](https://discuss.elastic.co/t/showing-values-in-a-graphic-bar/361025.md?page=2)
