# Variable Decimal places on a math column

**URL:** <https://community.glideapps.com/t/variable-decimal-places-on-a-math-column/83527>\
**Category:** Ask for Help\
**Created:** [July 29, 2025, 2:53pm UTC](https://community.glideapps.com/t/variable-decimal-places-on-a-math-column/83527 "2025-07-29T14:53:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_Goodman](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/tony_goodman/32/90798_2.png) [@Tony\_Goodman](https://community.glideapps.com/u/Tony_Goodman)\
**Post date:** [July 29, 2025, 2:53pm UTC](https://community.glideapps.com/t/variable-decimal-places-on-a-math-column/83527/1 "2025-07-29T14:53:29Z")

</div>

Hi All

I am trying to work out how to have a math column with variable decimal places, or precision.

As an example, I have a result which is LOAD1 - AFNT1, or 1.000 - 0.998 which would give me -0.002

In this example I have 3 decimal places, and would work fine if I set the precision on the column to 0.000, however this can vary by item.

I have a column that tells me how many decimal places there are (0,1,2,3,4 eg) which is called DECPLACES, so is there a way to tell glides math column how many decimal places to use from this data to calculate the result?

Hoping someone can help with this.

---

<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:** [July 29, 2025, 3:49pm UTC](https://community.glideapps.com/t/variable-decimal-places-on-a-math-column/83527/2 "2025-07-29T15:49:07Z")

</div>

I haven’t tried it dynamically, but I think you can set your math column precision to 4 decimal places, and then do the rounding in your math formula.

`Round(LOAD1-AFNT1, DECPLACES)`

---

<div class="post-metadata">

**Author:** ![Nicolas\_Joseph](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nicolas_joseph/32/76105_2.png) [@Nicolas\_Joseph](https://community.glideapps.com/u/Nicolas_Joseph)\
**Post date:** [July 29, 2025, 4:31pm UTC](https://community.glideapps.com/t/variable-decimal-places-on-a-math-column/83527/3 "2025-07-29T16:31:26Z")

</div>

Hi @Tony_Goodman and welcome 🙂

In addition to @Jeff_Hager’s answer, be also aware there is a difference between the **stored result** and the **displayed result**.

With your own example, you could have define the right calculation to get 3 decimals but only let the user see 1 decimal. The stored result would - indeed - be -0.002 but the user would probably see -0.0.

This is what you select in the _Display_ section of the _Math_ column.

* * *

### Some considerations

If it is your concern to also have a different result displayed, you could go for multiple _Math_ columns and an _If → Then → Else_ one to deal with this display question.

Here is a quick sample, a wonderful **`Decimals`** table:

 ![Decimals](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/5/55aa1023fc24fe34f2f7a32d7f33fe244178dac4.png)

  

Also this is the set up of some columns for the record:

| `Round 2 decimals` | `Round 8 decimals` |
| --- | --- |
| ![Round 2 decimals](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/5/155f27f7d5f645489fd9f75030c056f704f0f626.png) | ![Round 8 decimals](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/1/51d0ba51f0524c5afa8b911fdedef432d732a8d7.png) |

As you can see, the _Precision_ is set to **1** in `Round 8 decimals`.  
However, it has no consequences when it comes to the final step, the `Final result` column:

 ![Final format](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/e/6efbd4c8fe17e9b11904672203c936e64a2449e7.png)

Because the _Square root of 2_ has no value in `Number of decimals`, the _Else_ condition is applied, meaning it gets the rounded value to 8 decimals. And it actually displays 8 decimals here 😉

---

<div class="post-metadata">

**Author:** ![Tony\_Goodman](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/tony_goodman/32/90798_2.png) [@Tony\_Goodman](https://community.glideapps.com/u/Tony_Goodman)\
**Post date:** [August 4, 2025, 10:08am UTC](https://community.glideapps.com/t/variable-decimal-places-on-a-math-column/83527/4 "2025-08-04T10:08:30Z")

</div>

Thanks so much for this… My only concern here is that there are maybe 30 fields like this on the sheet I am creating, so each one perhaps needs 4 or 5 additional fields just to calculate this result… will this not bloat it?

---

<div class="post-metadata">

**Author:** ![Nicolas\_Joseph](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nicolas_joseph/32/76105_2.png) [@Nicolas\_Joseph](https://community.glideapps.com/u/Nicolas_Joseph)\
**Post date:** [August 4, 2025, 7:25pm UTC](https://community.glideapps.com/t/variable-decimal-places-on-a-math-column/83527/5 "2025-08-04T19:25:59Z")

</div>

If you want to avoid having to create **4 or 5 columns for single field** (and multiplying that by 30 in your case), there is a more direct approach using a _JavaScript_ column.  
It wasn’t mentioned in the previous answer because it’s slightly outside the scope of no-code logic obviously. However I believe it makes sense here.

### JavaScript column

Instead of the steps described ealier, siply add a _JavaScript_ column and configure it like this:

 ![JavaScript](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/2/028ebce060d77187030f2ddbf0e49465853cce6c.png)

Here is the code:

```JS
let value = p1;
let decimals = p2;
return value.toFixed(decimals)

```

It would also work with just `return p1.toFixed(p2)` - the classic readability versus conciseness dilemma 😌

> This code uses the value of p1 (which corresponds to `Value` in the screenshot) and returns it with the number of decimals specified in the `Number of decimals` column - the p2 parameter. Note that when the number of decimals is not filled (e.g. in the third row), the default behaviour is to remove all decimals.

  

### A tip when using JS

Assuming you go down this path, here’s a useful tip:

- Create a _Template_ column to store the code directly in the table  
 ![Template JS code](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/1/91db376e613db84566ec8fa96a8415964f4602b8.png)
- Then, instead of writing the actual code in the _JavaScript_ column, reference the template column we just created:  
 ![JS toFixed with Template](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/6/86b74e2ecec042a98bb42f88809d03d74d662f6b.png)

Since you’ll be applying the same function across 30 columns, ithis approach makes your logic easier to maintain, more scalable and less prone to typos 😉

> Ideally, this _Template_ column should be stored in the **`Users`** table - this way , you’ll be able to reuse the same function in any other table within your app.  
> Very helpful when you’re applying the same logic in multiple areas (I saw this in one of Marco Volpato’s tutorials - brilliant 👍)

  

### Performances

It’s very difficult to provide feedback on performance-related questions. It depends on many factors, even though there are some generally valid tips - such as avoiding _If → Then → Else_ columns with many conditions.  
One thing that’s easy to do, however, is to activate a feature called _Analyse Table Performance_, available under _Settings → Developper Tools_

 ![Analyze Table Performance](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/2/82f68f68fbb89fc57db18c472559759fdaa91a4c.png)

  

You can now run the analysis on your table and identify possible bottlenecks:

 ![Performances step 1](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/2/c/2c20e1f1cb2e859b9ab73fe29de339350b3ca6af.png)  
 ![Performances step 2](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/8/08eebef39e96571723b64504aff5d7b1aca1be72.png)

  

Hope this is what you were looking for! 🙂

---

<div class="post-metadata">

**Author:** ![Tony\_Goodman](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/tony_goodman/32/90798_2.png) [@Tony\_Goodman](https://community.glideapps.com/u/Tony_Goodman)\
**Post date:** [August 6, 2025, 1:47pm UTC](https://community.glideapps.com/t/variable-decimal-places-on-a-math-column/83527/6 "2025-08-06T13:47:27Z")

</div>

Thats great, thank you! I will have a play around with this and report back

---

<div class="post-metadata">

**Author:** ![Tony\_Goodman](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/tony_goodman/32/90798_2.png) [@Tony\_Goodman](https://community.glideapps.com/u/Tony_Goodman)\
**Post date:** [August 6, 2025, 3:07pm UTC](https://community.glideapps.com/t/variable-decimal-places-on-a-math-column/83527/7 "2025-08-06T15:07:42Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/2/3/230ab0f0d0665d081b559a505512ccd551187aab.png)

Not sure I am entirely getting it (frustratingly, i usually get things quickly!), however I am getting this TypeError when I edit the column… ive tried both ways of doing the JS but it still returns the same, and my results strangely have no decimal places in them regardless of what is in the DecimalPlaces column.

---

<div class="post-metadata">

**Author:** ![Tony\_Goodman](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/tony_goodman/32/90798_2.png) [@Tony\_Goodman](https://community.glideapps.com/u/Tony_Goodman)\
**Post date:** [August 6, 2025, 3:12pm UTC](https://community.glideapps.com/t/variable-decimal-places-on-a-math-column/83527/8 "2025-08-06T15:12:23Z")

</div>

Scrub that, as soon as I posted it I saw the error, DecimalPlaces was just text and not the Column Name… getting somewhere now!

---

<div class="post-metadata">

**Author:** ![Tony\_Goodman](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/tony_goodman/32/90798_2.png) [@Tony\_Goodman](https://community.glideapps.com/u/Tony_Goodman)\
**Post date:** [August 7, 2025, 7:25am UTC](https://community.glideapps.com/t/variable-decimal-places-on-a-math-column/83527/9 "2025-08-07T07:25:21Z")

</div>

nicolas\_joseph, just wanted to say thank you, all working well!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [August 14, 2025, 7:25am UTC](https://community.glideapps.com/t/variable-decimal-places-on-a-math-column/83527/10 "2025-08-14T07:25:22Z")

</div>

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