# Color coding bar metric

**URL:** <https://discuss.elastic.co/t/color-coding-bar-metric/380489>\
**Category:** Kibana\
**Created:** [July 28, 2025, 8:59am UTC](https://discuss.elastic.co/t/color-coding-bar-metric/380489 "2025-07-28T08:59:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon\_Thies](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simon_thies/32/144331_2.png) [@Simon\_Thies](https://discuss.elastic.co/u/Simon_Thies)\
**Post date:** [July 28, 2025, 8:59am UTC](https://discuss.elastic.co/t/color-coding-bar-metric/380489/1 "2025-07-28T08:59:26Z")

</div>

Hey there.  
I am currently setting up a dashboard with some bar diagrams.  
It is possible to set different colors for entries. But is it also possible to have a wildcard in the selection?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/9/d960efd573b95076e4db6d4daed083a26e178a09.png)  
For example, having anything starting with "SMP" in one color?  
"SMP\*", would be my first guess, but it doesn't seem to work.

Is there another solution?

---

<div class="post-metadata">

**Author:** ![Tortoise](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tortoise/32/147587_2.png) [@Tortoise](https://discuss.elastic.co/u/Tortoise)\
**Post date:** [July 28, 2025, 9:42am UTC](https://discuss.elastic.co/t/color-coding-bar-metric/380489/2 "2025-07-28T09:42:18Z")

</div>

Hello @Simon_Thies

Welcome to the community!!

In Lens I was not able to use the color as Men's\* or Women's\* , same issue as you reported.

As a work around I did below to use the color in it is helpful :

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

For my current field say category.keyword, i had above values.

Using below runtime field I divided the data into required categories of color example Men's & Women's

```auto
if (doc['category.keyword'].size() != 0) {
  def val = doc['category.keyword'].value;
  if (val.contains("Women's")) {
    emit("Women's");
  } else if (val.contains("Men's")) {
    emit("Men's");
  }
}

```

Then since now there are only 2 values for my new field , I have applied the color on this new field category\_runtime & same is available on the chart.

Thanks!!

---

<div class="post-metadata">

**Author:** ![Simon\_Thies](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simon_thies/32/144331_2.png) [@Simon\_Thies](https://discuss.elastic.co/u/Simon_Thies)\
**Post date:** [July 28, 2025, 10:13am UTC](https://discuss.elastic.co/t/color-coding-bar-metric/380489/3 "2025-07-28T10:13:11Z")

</div>

Hey, thanks for your reply.  
The solution indeed looks nice, but I can't figure out, where to set a runtime field.

---

<div class="post-metadata">

**Author:** ![Tortoise](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tortoise/32/147587_2.png) [@Tortoise](https://discuss.elastic.co/u/Tortoise)\
**Post date:** [July 28, 2025, 10:20am UTC](https://discuss.elastic.co/t/color-coding-bar-metric/380489/4 "2025-07-28T10:20:47Z")

</div>

Hello @Simon_Thies

For the index , if you have configured a data view so going to Discover using below option can add a runtime field :

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

Thanks!!

---

<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:** [July 28, 2025, 1:52pm UTC](https://discuss.elastic.co/t/color-coding-bar-metric/380489/5 "2025-07-28T13:52:23Z")

</div>

Hi @Simon_Thies

while it is not possible to apply partial matching to the Lens color mapping feature, I've found a close feature request you could track for it here: [[Lens] Improve color assignment UI for multi fields · Issue #202822 · elastic/kibana · GitHub](https://github.com/elastic/kibana/issues/202822)
