# Graphing boolean values after setting static convert to 0 and 1

**URL:** <https://discuss.elastic.co/t/graphing-boolean-values-after-setting-static-convert-to-0-and-1/327108>\
**Category:** Kibana\
**Tags:** elastic-stack-graph, visualisation\
**Created:** [March 6, 2023, 4:32pm UTC](https://discuss.elastic.co/t/graphing-boolean-values-after-setting-static-convert-to-0-and-1/327108 "2023-03-06T16:32:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shelby](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@shelby](https://discuss.elastic.co/u/shelby)\
**Post date:** [March 6, 2023, 4:32pm UTC](https://discuss.elastic.co/t/graphing-boolean-values-after-setting-static-convert-to-0-and-1/327108/1 "2023-03-06T16:32:13Z")

</div>

I have a boolean field in my index.  
I apply the static conversion to 0,1

I just want to create a simple graph with Timestamp on ths x-axis and 0 or 1 (or empty) on the y axis. However, when I go to lens to try to create the graph I am getting:

"This field does not work with the selected function."

For the function I select "Last Value".

I have the same when I try average or most of the others except Count which works.

However the documentation here:

> **[Boolean field type | Elasticsearch Guide \[8.7\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/boolean.html)**

states that

Aggregations like the [`terms` aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html) use `1` and `0` for the `key` , and the strings `"true"` and `"false"` for the `key_as_string` . Boolean fields when used in scripts, return `true` and `false`

so why I am not able to select average? else I have no way to visualize this data.

As an alternative is there some way for me to use max or min on a boolean by somehow convertint it to 1, 0.

again I tried to apply a static mapping to 0 and 1, but it is not working. I still get "This field does not work with the selected function."

---

<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:** [April 3, 2023, 4:32pm UTC](https://discuss.elastic.co/t/graphing-boolean-values-after-setting-static-convert-to-0-and-1/327108/2 "2023-04-03T16:32:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![drewdaemon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drewdaemon/32/97779_2.png) [@drewdaemon](https://discuss.elastic.co/u/drewdaemon)\
**Post date:** [April 11, 2023, 7:18pm UTC](https://discuss.elastic.co/t/graphing-boolean-values-after-setting-static-convert-to-0-and-1/327108/3 "2023-04-11T19:18:54Z")

</div>



---

<div class="post-metadata">

**Author:** ![drewdaemon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drewdaemon/32/97779_2.png) [@drewdaemon](https://discuss.elastic.co/u/drewdaemon)\
**Post date:** [April 11, 2023, 7:31pm UTC](https://discuss.elastic.co/t/graphing-boolean-values-after-setting-static-convert-to-0-and-1/327108/4 "2023-04-11T19:31:28Z")

</div>

Hi @shelby . Welcome to our community. I'm sorry that you didn't get a reply here sooner.

I have a couple of questions about what you're seeing:

> [@shelby](#):
>
> I apply the static conversion to 0,1

I'm not familiar with this technique. Are you using a runtime field?

> [@shelby](#):
>
> "This field does not work with the selected function."
> 
> For the function I select "Last Value".

Does your field have a pound sign beside it indicating that it is a numeric field?  
 ![Screenshot 2023-04-11 at 2.29.39 PM](https://us1.discourse-cdn.com/elastic/original/3X/e/f/ef43911e8189631ce3a2f3e98d2c4ac9760b19d7.png)

---

<div class="post-metadata">

**Author:** ![shelby](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@shelby](https://discuss.elastic.co/u/shelby)\
**Post date:** [April 12, 2023, 2:20pm UTC](https://discuss.elastic.co/t/graphing-boolean-values-after-setting-static-convert-to-0-and-1/327108/5 "2023-04-12T14:20:01Z")

</div>

Hello,  
thanks for your reply, actually, I chose a different approach where I use an integer field rather than boolean and can then use the various functions without VEGA code (avg, median, max...)

---

<div class="post-metadata">

**Author:** ![drewdaemon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drewdaemon/32/97779_2.png) [@drewdaemon](https://discuss.elastic.co/u/drewdaemon)\
**Post date:** [April 12, 2023, 6:59pm UTC](https://discuss.elastic.co/t/graphing-boolean-values-after-setting-static-convert-to-0-and-1/327108/6 "2023-04-12T18:59:23Z")

</div>

I'm glad you were able to find a solution!
