3 Replies Latest reply on May 22, 2012 10:57 AM by philmodjunk

    Forcing decimal points



      Forcing decimal points




      I have a text field where I display USD when we have a US customer and simply a dollar sign infront of the the total when we deal with our canandian customers.

      If (InterimContacts::Currency = "USD";
      "USD$" & Round(SubTotal+LevyCalc+PriceAdjustment;2);
      "$" & Round(SubTotal+LevyCalc+PriceAdjustment;2))

      The problem with my formula is that I used to use the data formatting in the inspector to force fthe required decimal points and left the feidl as a number field. I've now been asked to include the USD and can seem to narrow it down just right.


        • 1. Re: Forcing decimal points

          I did a quick test and see what you mean. If you use number as your return type, you can't also use number data formatting or you only see the number part of your value.

          I'd use either two fields or layout text with conditional formatting for this.

          Field1 or layout text provides "USD" when InterimContacts::Currency = "USD"; Field 2 is your number field with currency formatting.

          On your layout, you can put them together so that they appear to be a single field.

          (With layout text and a conditional format expression, you can set the font size of Layout text "USD" to 500 when InterimContacts::Currency does not equal "USD" and then the layout text disappears.)

          It's also possible to modify your calculation to append trailing 00 after the decimal--which may be needed if you are going to export the data. But if you were OK with data formatting originally, then such a more complex solution doesn't seem needed here.

          • 2. Re: Forcing decimal points

            Ideally I'd like to have the USD in the field itself so that if the price is only in 5 digits, the dollar amount can still properly be centered within the field making it clearer and look proper.


            I know I can add "0's" at the end of the calculation but I don't know of a function that works like Right or Left but starting from the decimal point.

            • 3. Re: Forcing decimal points

              Let ( [ I = Int ( numberField ) ;
                        d = Filter ( numberfield - I ; 9876543210)
                      I & "." & Left ( d & "00" )