# How to properly display prices in Kibana

**URL:** <https://discuss.elastic.co/t/how-to-properly-display-prices-in-kibana/247563>\
**Category:** Kibana\
**Created:** [September 4, 2020, 3:10pm UTC](https://discuss.elastic.co/t/how-to-properly-display-prices-in-kibana/247563 "2020-09-04T15:10:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jackson](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@Jackson](https://discuss.elastic.co/u/Jackson)\
**Post date:** [September 4, 2020, 3:10pm UTC](https://discuss.elastic.co/t/how-to-properly-display-prices-in-kibana/247563/1 "2020-09-04T15:10:05Z")

</div>

Hello,

I'm trying to properly display prices in Kibaba.

Currently, prices are mapped as a long integer so that 120.00 is stored as 12000. We have some dashboards we show to clients such as their total revenue. I need to display these properly as 120.00.

I've seen that it's recommended to store prices as floating points scaled to 100. However, the lead developer doesn't want to do this as he fears floating points sometimes don't convert properly. For example, he says converting 10000 cents into dollars could yield 99.99999999997.

Any advice on getting this working would be most appreciated. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![mikecote](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikecote/32/58549_2.png) [@mikecote](https://discuss.elastic.co/u/mikecote)\
**Post date:** [September 4, 2020, 4:17pm UTC](https://discuss.elastic.co/t/how-to-properly-display-prices-in-kibana/247563/2 "2020-09-04T16:17:45Z")

</div>

You should be able to display them formatted properly by creating a scripted field with the following painless script.

```auto
return (doc['total_quantity'].value / 100.0);

```

You can also change the formatting to `$0,0.00`.

---

<div class="post-metadata">

**Author:** ![Jackson](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@Jackson](https://discuss.elastic.co/u/Jackson)\
**Post date:** [September 5, 2020, 6:27pm UTC](https://discuss.elastic.co/t/how-to-properly-display-prices-in-kibana/247563/3 "2020-09-05T18:27:41Z")

</div>

Thanks for the reply.

Because many documents don't have a value for "price", I got an error. I used an IF statement to fix this and when I preview the scripted field, I get the correct result.

```auto
    if (doc['price'].size() > 0) { 
        return doc['price'].value / 100.00;
    }    

```

 ![Screen Shot 2020-09-05 at 7.13.02 PM](https://us1.discourse-cdn.com/elastic/original/3X/1/8/1887302cbeaaa256425fc9f255057dd6db0460c8.png)

I understand using a scripted field uses more resources as the script runs every time a search is made or visualization refreshed. Is there any way to optimize this or reduce server load?

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [September 6, 2020, 5:56pm UTC](https://discuss.elastic.co/t/how-to-properly-display-prices-in-kibana/247563/4 "2020-09-06T17:56:15Z")

</div>

> [@Jackson](#):
>
> Is there any way to optimize this or reduce server load?

The best way would be to format the data the way you want prior or during ingest, but it sounds like your developer doesn't want to.

If you are ingesting data through Logstash you can do all this in a Logstash filter.

---

<div class="post-metadata">

**Author:** ![Jackson](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@Jackson](https://discuss.elastic.co/u/Jackson)\
**Post date:** [September 10, 2020, 1:29pm UTC](https://discuss.elastic.co/t/how-to-properly-display-prices-in-kibana/247563/5 "2020-09-10T13:29:46Z")

</div>

The scripted field works great but I'm experiencing a problem.

I added the scripted filed to filebeat-\* However, periodically it simply disappears and I need to recreate the scripted field manually.

Any ideas about how to make this stop?

---

<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:** [October 8, 2020, 1:29pm UTC](https://discuss.elastic.co/t/how-to-properly-display-prices-in-kibana/247563/6 "2020-10-08T13:29:52Z")

</div>

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