# 🤔 How to: Remove .00 from Math column numbers without rounding up/down with "Precision 1"? (w/ pic)

**URL:** <https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205>\
**Category:** Ask for Help\
**Created:** [May 8, 2024, 9:27pm UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205 "2024-05-08T21:27:32Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamieErvin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jamieervin/32/57900_2.png) [@JamieErvin](https://community.glideapps.com/u/JamieErvin)\
**Post date:** [May 8, 2024, 9:27pm UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/1 "2024-05-08T21:27:32Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/7/4730d2e06cc58aace1af5247f25df52c3fb37e06.png)

Hello!

I’m not sure I’m asking this correctly.

I’d like to eliminate the .00 after my numbers but “Precision 1” rounds the numbers (which I don’t want).

I need whole numbers with no .00 if possible.

Is there an alternative?

Thanks

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/7/4730d2e06cc58aace1af5247f25df52c3fb37e06.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [May 8, 2024, 10:06pm UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/2 "2024-05-08T22:06:27Z")

</div>

Are you saying that sometimes you do have decimal amounts, but you want to truncate the decimal instead of round it? Just basing off your examples you have .00, so there would be no rounding taking place if you set precision to 1. Just want to make sure I understand what kinds of numbers you are working with. There are math formulas such as Floor or Trunc which would work for you, but I’m not sure you need to take it that far.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 8, 2024, 11:55pm UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/3 "2024-05-08T23:55:27Z")

</div>

Would be better if we hear from him what he expects in these test cases:

123.00  
123.01  
123.06

---

<div class="post-metadata">

**Author:** ![JamieErvin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jamieervin/32/57900_2.png) [@JamieErvin](https://community.glideapps.com/u/JamieErvin)\
**Post date:** [May 9, 2024, 3:31am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/4 "2024-05-09T03:31:15Z")

</div>

@Jeff_Hager @ThinhDinh

Thanks for the reply.

These are mostly going to be whole numbers usually with occasional .5:  
“This is a 1 spread” (rather than 1.0 spread)  
“This spread is 1.5” (and 1.50 is fine here)

“This is a 2.25 spread” (perfect, not rounded up)  
“This is a 2.5 spread” (this is fine because 2.5 and 2.50 works for us, here)

In the column called premium we’d prefer:  
“Premium (cr) .12” (rather than 0.12)

Also for the sleg column, most of those whole numbers end with 5 or 0.  
“225” (not 225.00)  
“225.50” (without rounding up but 225.5 is ok here too).

Hope that makes sense.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [May 9, 2024, 4:04am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/5 "2024-05-09T04:04:16Z")

</div>

I don’t know if that cleared things up or made me more confused. Is this more of a cosmetic thing where you just want to remove any leading or trailing zeros?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [May 9, 2024, 4:07am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/6 "2024-05-09T04:07:37Z")

</div>

Please answer the question from @ThinhDinh …

> [@ThinhDinh](#):
>
> Would be better if we hear from him what he expects in these test cases:
> 
> 123.00  
> 123.01  
> 123.06

Given each of the above, what would you expect as the output?

---

<div class="post-metadata">

**Author:** ![JamieErvin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jamieervin/32/57900_2.png) [@JamieErvin](https://community.glideapps.com/u/JamieErvin)\
**Post date:** [May 9, 2024, 5:36am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/7 "2024-05-09T05:36:10Z")

</div>

Yes.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [May 9, 2024, 5:53am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/8 "2024-05-09T05:53:55Z")

</div>

Try this in a javascript column. The p1 parameter would be your number.

```auto
function trimLeadingAndTrailingZeros(number) {
    
    // Convert number to string
    let strNum = String(number);
    
    // Trim leading zeros
    strNum = strNum.replace(/^0+/, '');
    
    // Trim trailing zeros
    strNum = strNum.replace(/0+$/, '');
    
    // Check if number is valid
    if (isNaN(strNum) || !strNum) {
        return '0'; 
    }

    return strNum;
}

return trimLeadingAndTrailingZeros(p1)

```

---

<div class="post-metadata">

**Author:** ![JamieErvin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jamieervin/32/57900_2.png) [@JamieErvin](https://community.glideapps.com/u/JamieErvin)\
**Post date:** [May 9, 2024, 5:58am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/9 "2024-05-09T05:58:28Z")

</div>

Thank you. I’m too new to understand what to do with that information, though.

Where do I put it?

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [May 9, 2024, 6:06am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/10 "2024-05-09T06:06:47Z")

</div>

> [@Jeff\_Hager](#):
>
> Try this in a javascript column

 ![Screenshot_20240509-010619](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/e/eec2a614c5d335760061437dd41fefcb937cebe8.jpeg)

---

<div class="post-metadata">

**Author:** ![JamieErvin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jamieervin/32/57900_2.png) [@JamieErvin](https://community.glideapps.com/u/JamieErvin)\
**Post date:** [May 9, 2024, 6:24am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/11 "2024-05-09T06:24:01Z")

</div>

Ohhhhh!??? 🤔

All of the Glide community help posts I ran search implied JavaScript wasn’t supported.

So it’s in a column now! Got it! 👍

Will implement ASAP and report back!

Thanks Jeff!

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [May 9, 2024, 6:28am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/12 "2024-05-09T06:28:14Z")

</div>

JavaScript is not supported on the front end, such as in a Rich Text component, or injecting javascript some other way. It’s always been available through the back end in the table as a column type.

---

<div class="post-metadata">

**Author:** ![JamieErvin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jamieervin/32/57900_2.png) [@JamieErvin](https://community.glideapps.com/u/JamieErvin)\
**Post date:** [May 11, 2024, 10:00pm UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/13 "2024-05-11T22:00:47Z")

</div>

> [@Jeff\_Hager](#):
>
> ```auto
> function trimLeadingAndTrailingZeros(number) {
>     
> // Convert number to string
> let strNum = String(number);
>     
> // Trim leading zeros
> strNum = strNum.replace(/^0+/, '');
>     
> // Trim trailing zeros
> strNum = strNum.replace(/0+$/, '');
>     
> // Check if number is valid
> if (isNaN(strNum) || !strNum) {
> return '0'; 
> }
> 
> return strNum;
> }
> 
> return trimLeadingAndTrailingZeros(p1)
> 
> ```

First of all, thank you for this. Much appreciated.

Secondly, am I to understand that I would need to create a javascipt column for each number I need?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 11, 2024, 11:50pm UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/14 "2024-05-11T23:50:23Z")

</div>

If you mean you need them to format different columns, then yes, each column requires a JS companion.

---

<div class="post-metadata">

**Author:** ![JamieErvin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jamieervin/32/57900_2.png) [@JamieErvin](https://community.glideapps.com/u/JamieErvin)\
**Post date:** [May 12, 2024, 3:03am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/15 "2024-05-12T03:03:51Z")

</div>

Let me rephrase what I mean.

I understand the script will format the column.

So in this case will (p1) be the same number on every row in this case the .21

OR

Is there a way to adjust this so that I can have the script trimming each of the numbers in a column instead of just one number I put in p1?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/1/c1cbcb35c5468e481075ec4bc68eb3ad50dc367f.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [May 12, 2024, 3:39am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/16 "2024-05-12T03:39:37Z")

</div>

You are specifying a column for your p1 parameter. With that, the javascript will run for each value in each row. It would only be the same if you were to hard coded an actual number instead of specifying a column.

With that, the code you copied and pasted doesn’t appear to be formatted the same as what I shared, which is leading the the error you are seeing. It’s important that it looks the same.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [May 12, 2024, 5:00am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/17 "2024-05-12T05:00:57Z")

</div>

For what it’s worth, you can get the same effect as the JavaScript with an if-then-else column:

 ![CleanShot 2024-05-12 at 12.53.25@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/d/edfae07ae26fed3d736d998b5ce0fd89c3a2a775.png)

 ![CleanShot 2024-05-12 at 13.02.00@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/5/c5e6b17aaf1b513a76e35ffb892a3f84b345af44.png)

This is something I stumbled upon a couple of months ago. As long as you have at least two IF cases, it will work - in the sense that fractional numbers have trailing zeros removed, and exact numbers are returned whole. I accidentally discovered this behaviour whilst looking for a solution for a client that had _exactly_ this requirement.

---

<div class="post-metadata">

**Author:** ![JamieErvin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jamieervin/32/57900_2.png) [@JamieErvin](https://community.glideapps.com/u/JamieErvin)\
**Post date:** [May 12, 2024, 6:16am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/18 "2024-05-12T06:16:11Z")

</div>

Thank you kindly! I’ll implement pronto and report back!

---

<div class="post-metadata">

**Author:** ![nathanaelb](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nathanaelb/32/43079_2.png) [@nathanaelb](https://community.glideapps.com/u/nathanaelb)\
**Post date:** [May 12, 2024, 8:20am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/19 "2024-05-12T08:20:48Z")

</div>

What a nice hidden “feature”. Very random (no pun intended) but useful. I have no idea how I could remember that though 😅

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 13, 2024, 12:12am UTC](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205/20 "2024-05-13T00:12:27Z")

</div>

> [@Darren\_Murphy](#):
>
> This is something I stumbled upon a couple of months ago. As long as you have at least two IF cases, it will work - in the sense that fractional numbers have trailing zeros removed, and exact numbers are returned whole. I accidentally discovered this behaviour whilst looking for a solution for a client that had _exactly_ this requirement.

This is pure magic.

[Next page](https://community.glideapps.com/t/how-to-remove-00-from-math-column-numbers-without-rounding-up-down-with-precision-1-w-pic/73205.md?page=2)
