How to keep decimal value in Number() expression?

I have a formular to extract number from a string. After successfully extract the digits; I convert it to Number for calculation. However, the decimal value is not retained after converted.

Example: Number(“0.08”) => 0 (zero).

My app is using english locale.

Is there any way i can convert number-like text with decimals to number?

Based on understanding of your description, you wish to extract a decimal value from a text string and further use it for calculation.

If so please try the following expression in a decimal type column.

INDEX(EXTRACTNUMBERS([Text_Column]),1)

The above assumes that there is one decimal value in the [Text_Column] that you wish to extract and save it in a decimal type column for further calculation.

So, if the [Text_Column] contains a text string say , “The weight of the baggage is 75.35 kgs” , the result in the decimal column would be 75.35

Example below:

The text string is hardcoded in a decimal type VC.

The test pane shows the result as below

The result is shown in the detail view as below

6 Likes

Oh my god sir! I bow my hat to you. I have been pulling my hair for days to solve this matter but failed.

Number(“0.0123”) whatever always return 0 to me;

Split() also does not help!

But ExtractNumbers give me exactly the number i need WITH decimal!
Is it new function or what? I have not touched appsheet for quite a time.

3 Likes

You are welcome. I believe EXTRACT() functions have been around for 5 + years.

In general you could have also used DECIMAL(“0.0123”) instead of NUMBER(“0.0123”) to retain the decimal places. Wrapping with NUMBER() strips the number value of any decimal places and returns an integer value in AppSheet.

However , I believe you are working with text strings. So using EXTRACTNUMBERS() is a better option than other composite expressions to first extract number from the string and then converting it to a decimal value.

3 Likes

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