19

I am using a formula field to concatonate 2 decimal values separated by a dash. However, I want the result to trim all unneccesary trailing zeros and decimal points for both values.

For example, I want values 10 and 8.5 to be "10 - 8.5". Now it shows "10.00 - 8.50".

The formula I am using is CSTR({field1}) + " - " + CSTR({field2}).

Breeze
  • 2,010
  • 2
  • 32
  • 43
Mike Cole
  • 14,474
  • 28
  • 114
  • 194

3 Answers3

34

I believe this is what you're looking for:

Convert Decimal Numbers to Text showing only the non-zero decimals

Especially this line might be helpful:

StringVar text     :=  Totext ( {Your.NumberField} , 6 , ""  )  ;

The first parameter is the decimal to be converted, the second parameter is the number of decimal places and the third parameter is the separator for thousands/millions etc.

mark_h
  • 5,233
  • 4
  • 36
  • 52
Sam Trost
  • 2,173
  • 20
  • 26
28
CSTR({number_field}, 0, '')

The second placeholder is for decimals.

The last placeholder is for thousands separator.

Paul Grimes
  • 379
  • 3
  • 2
1

i wrote a simple function for this:

Function (stringVar param)
(
    Local stringVar oneChar := '0';
    Local numberVar strLen := Length(param);
    Local numberVar index := strLen;

    oneChar = param[strLen];

    while index > 0 and oneChar = '0' do
    (
        oneChar := param[index];
        index := index - 1;
    );

    Left(param , index + 1);
)
Robert Niestroj
  • 15,299
  • 14
  • 76
  • 119