This website uses Cookies. Click Accept to agree to our website's cookie use as described in our Privacy Policy. Click Preferences to customize your cookie settings.

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Airtable Community
- Discussions
- Ask A Question
- Formulas
- How to create a 'Numbers' field WITHOUT uniform de...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Topic Labels:
Formulas

Solved

Jump to Solution

0
4525
8

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Comment Post Options

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Dec 21, 2019 06:39 PM

I need to record weight data for observations that have different levels of precision because they span a wide range and must be measured on different scales. Is there a way to allow for differing levels of decimal precision across entries in a single “Numbers” field?

For instance, to enter 4 sample measurements of: 3, 3.0, 3.02, and 3.020, Airtable makes me select a single level of decimal precision for all of the entries, so it ends up showing as something like: 3.000, 3.000, 3.020, 3.020 or 3, 3, 3, 3 or etc etc… You get the idea.

In any case, the resulting entries do not accurately reflect the actual data.

As far as I can tell, if I want to use this field for formula-based calculations, I must designate it a ‘numbers field’ and therefore must choose a single level of decimal precision for all of the entries.

Is there a way to get around this without misrepresenting my data precision and without creating separate weight fields for each level of decimal precision?

Thanks for the advice!

Solved! Go to Solution.

1 Solution

Accepted Solutions

Solved
See Solution in Thread

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Dec 24, 2019 03:17 PM

Okay, here’s the solution I came up with. Let me know how this works for your situation.

`{Number}`

is a Single Line Text field so that I can set any precision that I want, with that precision calculated in the `{Precision}`

field:

```
LEN(Number) - FIND(".", Number)
```

The `{Double}`

field formula is the pretty much the same as last time, outputting a string.

```
(VALUE(Number) * 2) & ""
```

I then use that in `{Double Display}`

to re-pad the necessary number of trailing zeroes to match the precision of the original.

```
IF(
Number,
Double &
IF(
NOT(FIND(".", Double)),
"."
) &
REPT(
"0",
Precision
+ (FIND(".", Double) = 0)
- LEN(MID(Double, FIND(".", Double) + 1, Precision))
)
)
```

When using this system yourself, you’d do something similar: have one formula that performs the actual calculation(s) you want and outputs a string, and another that reformats the result to match the original value’s precision.

Reply

8 Replies 8

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Dec 21, 2019 09:59 PM

There isn’t a way to format decimal numbers in Airtable with varying levels of precision, at least not while still treating them as numbers. If you convert them to a string, though, Airtable strips off any unnecessary trailing zeroes.

The formula in the `{Formula}`

field to force the number into a string is:

```
Number & ""
```

If you need to use that number in later calculations, wrap `VALUE()`

around the formula field reference that creates the string. Here’s one that simply doubles the value, then converts it back into a string:

```
(VALUE(Formula) * 2) & ""
```

Does this help?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Dec 22, 2019 05:24 PM

Thanks so much–that is a super useful formula that will come in handy. It is definitely better than being stuck with a uniform decimal precision, though… removing the trailing 0s is really only helpful when they’re added by Airtable based on the ‘number field’ precision setting.

When the trailing 0(s) represent part of an actual weight measurement I don’t want them to be stripped off because they convey the level of precision of the measurement and removing them would imply a less precise measurement than it actually is.

For instance, I have one scale that accurately measures to +/- 0.001g but can only handle a maximum weight of 200g and another scale that can measure up to many kilograms, but only to a precision of +/-0.1g… so for small samples (up to 250g) my sample data should have 3 decimals of precision (even if some of those digits happen to be 0), but larger samples should only have 1 decimal of precision at the gram scale.

So, by way of example, what I am trying to find is a way for both of these situations to be accommodated within a single data field:

- a record entered as 25.100 to stay as is (not to have the trailing 0s stripped to become 25.1 and thus underrepresent the actual precision of the measurement)
- a record entered as 250.1 to stay as is (not to have trailing zeros added to become something like 250.100 which implies overstated measurement precision)

and, - to be able to use the data above in numerical formulas.

I have a suspicion there are probably some workarounds possible if I keep the original data recorded as a ‘Short Line Text’ field and convert to numbers and keep track of decimal points for each record in each formula I use… but that is starting to feel way too complicated and clumsy, and I really hope there is a more direct way to handle this issue. I figured there had to be a simple solution that I was just missing because I can’t imagine this is a particularly uncommon situation. I’m really trying hard to keep all my data and analysis in Airtable, but it is hard to resist the urge to pull the little headache sections like this back over to Excel and undermine the whole streamlining effort.

Thanks so much for the 0 stripping trick and for any other tips you might have up your sleeve!

Best,

-D

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Dec 24, 2019 02:31 PM

I’m not sure what about a Single Line Text field would be either complicated or clumsy. The data you enter will remain exactly as entered: 25.100 stays 25.100, and 250.1 stays 250.1. Yes, it will require a bit more out of any formulas that reference the data, but not that much.

To turn the entered text into a value in a formula, wrap `VALUE()`

around the field reference as I mentioned above. If you need to maintain precision through a calculation, that’s also doable. I’m working my way through a solution for that now, and will post details when that’s done.

Solved
See Solution in Thread

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Dec 24, 2019 03:17 PM

Okay, here’s the solution I came up with. Let me know how this works for your situation.

`{Number}`

is a Single Line Text field so that I can set any precision that I want, with that precision calculated in the `{Precision}`

field:

```
LEN(Number) - FIND(".", Number)
```

The `{Double}`

field formula is the pretty much the same as last time, outputting a string.

```
(VALUE(Number) * 2) & ""
```

I then use that in `{Double Display}`

to re-pad the necessary number of trailing zeroes to match the precision of the original.

```
IF(
Number,
Double &
IF(
NOT(FIND(".", Double)),
"."
) &
REPT(
"0",
Precision
+ (FIND(".", Double) = 0)
- LEN(MID(Double, FIND(".", Double) + 1, Precision))
)
)
```

When using this system yourself, you’d do something similar: have one formula that performs the actual calculation(s) you want and outputs a string, and another that reformats the result to match the original value’s precision.

Reply

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Dec 26, 2019 05:45 AM

Thank you SO MUCH for all your work to help sort out a solution to my nit-picky problem! This approach works out great. Your expertise is so helpful, and the extra effort you so generously put in to work it through and explain step by step is SO greatly appreciated. You’ve solved my problem and taught me a ton in the process. Thanks again!

It is a shame that it takes such a convoluted work-around to effectively undo Airtable’s convenience feature of pre-specifying a number field’s decimal precision. If only there was a standard option to turn that feature on or off… :winking_face:

Thanks again for all your insight and patient guidance,

D

Reply

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Dec 26, 2019 06:06 AM

Hi @Daniel_MacPhee and @Justin_Barrett

I thought that Justin should see your wonderful reply, so I placed an ampersand (@) in front of his name, so he will see it for sure.

Mary K

Reply

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Dec 26, 2019 09:36 AM

thanks @M_k :slightly_smiling_face: :thumbs_up:

Reply

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Dec 26, 2019 12:34 PM

Reply