# formatNumber not working for Metric

**URL:** <https://discuss.elastic.co/t/formatnumber-not-working-for-metric/186958>\
**Category:** Kibana\
**Created:** [June 22, 2019, 2:02pm UTC](https://discuss.elastic.co/t/formatnumber-not-working-for-metric/186958 "2019-06-22T14:02:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbarnett](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@gbarnett](https://discuss.elastic.co/u/gbarnett)\
**Post date:** [June 22, 2019, 2:02pm UTC](https://discuss.elastic.co/t/formatnumber-not-working-for-metric/186958/1 "2019-06-22T14:02:23Z")

</div>

I'm trying to format a number with leading 0's in a Canvas Metric element. In the expression editor I have:

| math "count"  
| formatnumber format="0000"

It displays "count" just fine, but never with the leading 0's. If I change it to:

| math "count"  
| formatnumber format="0000.0"

Then it adds the .0 just fine, but still does not add the leading 0's. So, I know that my formatnumber function is being invoked, but never formats the number with the leading zeros that I need.

---

<div class="post-metadata">

**Author:** ![smac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smac/32/88776_2.png) [@smac](https://discuss.elastic.co/u/smac)\
**Post date:** [June 28, 2019, 2:23pm UTC](https://discuss.elastic.co/t/formatnumber-not-working-for-metric/186958/2 "2019-06-28T14:23:29Z")

</div>

Looks like an issue. You can use the following in your expression on the next line to add zeroes manually though.

```
| string "00" {context}
```

---

<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:** [July 26, 2019, 2:23pm UTC](https://discuss.elastic.co/t/formatnumber-not-working-for-metric/186958/3 "2019-07-26T14:23:33Z")

</div>

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