Forum Discussion

TroyTroy1's avatar
TroyTroy1
Qrew Trainee
7 years ago

Change entered values to positive or negative values

I have been requested to create a field that changes negative numbers to positive numbers and positives to negative numbers after being entered in the field. I looked at using the ABS but only works with converting negative values to positive but QB has a limitation preventing users from referencing the current field in the formula. 
Any help is greatly appreciated. 
Thanks

13 Replies

    • TroyTroy1's avatar
      TroyTroy1
      Qrew Trainee
      But A formula may not contain a reference to itself directly or indirectly through another formula?
    • QuickBaseCoachD's avatar
      QuickBaseCoachD
      Qrew Captain
      Are you trying to change the sign on a data entry field or a formula field.  if its a data entry field then you will nee to create a new field
  • >... too dangerous to change the user's actual input ...
    >...  never really being sure what the user entered ...

    Human input should always be verified and changed if incorrect, in the wrong format or if a typo is detected. Luckily it is simple to do with script. Here is the core code (for use with IOL) for negating the number entered by your human:
    $("#_fid_6").on("change", function() {
      $("#_fid_6").val(- parseFloat($("#_fid_6").val()));
    });
    Using a formula to do this only bloats your application with superfluous fields (assuming there is no need for retaining the human's original keystrokes).
    • HillaryWhitney's avatar
      HillaryWhitney
      Qrew Cadet
      Where would I place this script to change my field to a negative? Do I need to change my field type from currency to formula - numeric?

      ------------------------------
      Hillary Whitney
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Qrew Champion
        One way is to create a new formula field  with the formula

        -[field which is positive]


        ------------------------------
        Mark Shnier (YQC)
        Quick Base Solution Provider
        Your Quick Base Coach
        http://QuickBaseCoach.com
        mark.shnier@gmail.com
        ------------------------------