# Function "eq" is not working

**URL:** <https://discuss.elastic.co/t/function-eq-is-not-working/255466>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [November 16, 2020, 4:32am UTC](https://discuss.elastic.co/t/function-eq-is-not-working/255466 "2020-11-16T04:32:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tangkalo](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@tangkalo](https://discuss.elastic.co/u/tangkalo)\
**Post date:** [November 16, 2020, 4:32am UTC](https://discuss.elastic.co/t/function-eq-is-not-working/255466/1 "2020-11-16T04:32:00Z")

</div>

Hi, all. I have been scratching my head as to how I can conditionally change color of the context for a markdown. For some reason, the equality function "eq" doesn't seem to compare correctly. Even though the markdown displays the column value correctly in the workpad e.g. "warn", but the switch case test lands on the default. Am I missing something? Thanks in advance.

`| markdown "{{rows.0.overallStatus}}"`  
` font={font size=48 family="'Open Sans', Helvetica, Arial, sans-serif"`  
` color={`  
` switch {case if={eq "warn"} then="orange"}`  
` {case if={eq "ok"} then="green"}`  
` default="purple"`  
` }`  
` }`

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [November 18, 2020, 4:07am UTC](https://discuss.elastic.co/t/function-eq-is-not-working/255466/2 "2020-11-18T04:07:54Z")

</div>

According to [this](https://discuss.elastic.co/t/conditionals-in-canvas/168796/2)  
The syntax is

```auto
  fn=${getCell status | switch 
    {case if={compare eq to="up"} then=Healthy}
    {case if={compare eq to="down"} then=Unhealthy}
    default="Unknown"

```

Try changing your syntax accordingly.  
Thanks

---

<div class="post-metadata">

**Author:** ![tangkalo](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@tangkalo](https://discuss.elastic.co/u/tangkalo)\
**Post date:** [December 1, 2020, 10:46pm UTC](https://discuss.elastic.co/t/function-eq-is-not-working/255466/3 "2020-12-01T22:46:28Z")

</div>

Thanks. I was able to get it working with the following syntax: -

font={font color={if condition={getCell overallStatus | eq "error"} then="red"  
else if condition={getCell overallStatus | eq "warn"} then="orange"  
else="green"}}

---

<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:** [December 29, 2020, 10:46pm UTC](https://discuss.elastic.co/t/function-eq-is-not-working/255466/4 "2020-12-29T22:46:32Z")

</div>

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