3 Replies Latest reply on Aug 27, 2014 3:08 PM by philmodjunk

# how do i force a zero in front of a decimal point if value less than 1

### Title

how do i force a zero in front of a decimal point if value less than 1

### Post

anyone know how to force a zero to appear in a calculation if value is less than 1?

the field isn't used on any layout but called by a javascript variable so I cant use the field inspector decimal function.

thanks

• ###### 1. Re: how do i force a zero in front of a decimal point if value less than 1

It would appear that you need to treat the value of the field as text rather than a number.

If ( numberField < 1 and numberField > 0 ; "0" & NumberField ; NumberField)

Select text as a result type.

• ###### 2. Re: how do i force a zero in front of a decimal point if value less than 1

"how do i force a zero in front of a decimal point if value less than 1"

You can use this calculation into the option of auto-enter a calc for that field:

Case(
0 < Self and Self < 1 ; 0 & Self ;
-1 < Self and Self < 0 ; "-0" & Abs ( Self ) ;
Self
)

Note that the field could be a number field.
If the field is a calculation field you could arrange its calculation or use another calculation field, result number, like:

Let(
n = YourField ;
Case(
0 < n and n < 1 ; 0 & n ;
-1 < n and n < 0 ; "-0" & Abs ( n ) ;
n
)
)

• ###### 3. Re: how do i force a zero in front of a decimal point if value less than 1

Hmmm, I was being a bit cautious by recommending a text field as I don't know the process used to set a javascript variable to this field's value. My concern with a number field is that it might correctly display the leading zero, but fail to evaluate in a way that keeps that leading zero when assigning this value to the JavaScript variable.

So I really don't know if it has to be of type text or can be of type number, but  was much more confident that a text result would work in that context than would a number result. if the number data type works in this context, all the better.