# Number formatting

**URL:** <https://forums.losant.com/t/number-formatting/2168>\
**Category:** Help\
**Tags:** experience\
**Created:** [September 4, 2019, 6:44pm UTC](https://forums.losant.com/t/number-formatting/2168 "2019-09-04T18:44:08Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [September 4, 2019, 6:44pm UTC](https://forums.losant.com/t/number-formatting/2168/1 "2019-09-04T18:44:08Z")

</div>

I displaying some numbers from a pageData payload originating from a table.  
These numbers currently have 16 decimals, so is there a way to format that down to 3 decimals using handlebars?

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [September 4, 2019, 7:38pm UTC](https://forums.losant.com/t/number-formatting/2168/2 "2019-09-04T19:38:17Z")

</div>

Hi @Lars_Andersson,

The [{{format}} helper](https://docs.losant.com/workflows/accessing-payload-data/#format-helpers) should do the trick here!

Thanks,  
Julia

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [September 4, 2019, 8:12pm UTC](https://forums.losant.com/t/number-formatting/2168/3 "2019-09-04T20:12:16Z")

</div>

I tried {{format mynumber}} and {{format mynumber ‘,.6’}} but that didn’t change anything.

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [September 4, 2019, 8:33pm UTC](https://forums.losant.com/t/number-formatting/2168/5 "2019-09-04T20:33:26Z")

</div>

I think I figured that one out. the “mynumber” variable was a string.

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [September 4, 2019, 9:03pm UTC](https://forums.losant.com/t/number-formatting/2168/7 "2019-09-04T21:03:29Z")

</div>

Can I convert string to number with {{format}} too?  
I have tried to find that before asking, but no luck.

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [September 4, 2019, 9:19pm UTC](https://forums.losant.com/t/number-formatting/2168/9 "2019-09-04T21:19:16Z")

</div>

@Lars_Andersson,

I recommend using the [String Node](https://docs.losant.com/workflows/logic/string/#to-number). 🤗

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [September 4, 2019, 9:38pm UTC](https://forums.losant.com/t/number-formatting/2168/11 "2019-09-04T21:38:04Z")

</div>

Yeah, I was looking at that, but since I am calling rows from a table and not all columns should be converted to numbers, it seemed easier to just convert the proper DataTable columns from string to number, so that’s what I ended up doing.

---

<div class="post-metadata">

**Author:** ![David\_MacKenzie](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@David\_MacKenzie](https://forums.losant.com/u/David_MacKenzie)\
**Post date:** [June 16, 2020, 2:40pm UTC](https://forums.losant.com/t/number-formatting/2168/14 "2020-06-16T14:40:23Z")

</div>

How do I just “chop off” the decimal?

---

<div class="post-metadata">

**Author:** ![Aidan\_Zebertavage](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/aidan_zebertavage/32/2719_2.png) [@Aidan\_Zebertavage](https://forums.losant.com/u/Aidan_Zebertavage)\
**Post date:** [June 16, 2020, 3:53pm UTC](https://forums.losant.com/t/number-formatting/2168/16 "2020-06-16T15:53:34Z")

</div>

Hi @David_MacKenzie,

You have a few options depending on where you are working with these numbers within the Losant platform.

Within the visual workflow engine you can use the Math Node to perform a truncating function on the value ([https://docs.losant.com/workflows/accessing-payload-data/#supported-functions](https://docs.losant.com/workflows/accessing-payload-data/#supported-functions)).

You can also leverage the format helper guide to help with accessing and manipulating values from your payload. [https://docs.losant.com/workflows/accessing-payload-data/#format-helpers](https://docs.losant.com/workflows/accessing-payload-data/#format-helpers).

For your specific use, the option {{ format num .2 }} will result in the number formatted without the decimals.

Let us know if we can help further.

Thanks,  
@Aidan_Zebertavage

---

<div class="post-metadata">

**Author:** ![Aidan\_Zebertavage](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/aidan_zebertavage/32/2719_2.png) [@Aidan\_Zebertavage](https://forums.losant.com/u/Aidan_Zebertavage)\
**Post date:** [June 16, 2020, 4:23pm UTC](https://forums.losant.com/t/number-formatting/2168/18 "2020-06-16T16:23:03Z")

</div>

@David_MacKenzie,

A few more specifics regarding the `{{ format num '.2' }}` to clarify its use:

The .2 does need to be in quotes: ‘.2.’ , as seen above.  
The .2 refers to the number of significant digits to be reported, so a value like 1.2 will still result in 1.2.

To completely remove the decimal values, you could use fixed point notation: `{{format num '.0f'}}`

We have this linked in the Losant docs but more information on D3 formatting can be found here: [https://github.com/d3/d3-format#locale\_format](https://github.com/d3/d3-format#locale_format).

Thanks,  
@Aidan_Zebertavage

---

<div class="post-metadata">

**Author:** ![David\_MacKenzie](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@David\_MacKenzie](https://forums.losant.com/u/David_MacKenzie)\
**Post date:** [June 16, 2020, 4:26pm UTC](https://forums.losant.com/t/number-formatting/2168/21 "2020-06-16T16:26:23Z")

</div>

Thanks. I am too slow to figure out how this works.

I have an attribute that is a number type called TotalLenTravel. See the block/column below:

![image002.jpg](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/8/847245d1d9576ed4c6bb75bec3621b6fd6a6e6cb.jpeg)

I am trying to format in cell template box below:

 ![image004.jpg](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/0/0dc9183ee8e6bf2820d1cd5cb2e181e3ec7546e7.jpeg)

If I put what you suggested, nothing is displayed in table. Same with {{format value .2}}. Sadly, I am one of THOSE users….

---

<div class="post-metadata">

**Author:** ![Aidan\_Zebertavage](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/aidan_zebertavage/32/2719_2.png) [@Aidan\_Zebertavage](https://forums.losant.com/u/Aidan_Zebertavage)\
**Post date:** [June 16, 2020, 5:07pm UTC](https://forums.losant.com/t/number-formatting/2168/23 "2020-06-16T17:07:20Z")

</div>

@David_MacKenzie,

No problem at all! We are happy to help. Take a look at the attached screenshot here, I think we may just have some syntax issues in your cell template. When specifying the format type, you need quotes and the decimal point, no comma needed.

In my example I used `{{format value '.0f' }}` which took a simulated value for total length traveled of 600.754937 and truncates it down to 601 in the data table on the dashboard.

 ![Screen Shot 2020-06-16 at 12.43.17 PM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/7/71bd2b0f98a33ec2d0fedda4d7041864b3f54ba3.png)

Let me know if this solves the issue on your end.

Thanks,  
@Aidan_Zebertavage

---

<div class="post-metadata">

**Author:** ![David\_MacKenzie](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@David\_MacKenzie](https://forums.losant.com/u/David_MacKenzie)\
**Post date:** [June 16, 2020, 5:50pm UTC](https://forums.losant.com/t/number-formatting/2168/25 "2020-06-16T17:50:55Z")

</div>

Yes, that is exactly what I was looking for. Thank you.
