Discussions

 View Only
Expand all | Collapse all

Trying to keep the 0 after a decimal place in a numeric field eg. 1.10 1.20 etc

  • 1.  Trying to keep the 0 after a decimal place in a numeric field eg. 1.10 1.20 etc

    Posted 01-05-2018 01:35
    Numeric fields automatically remove the 0 at the end of a numeral with a decimal place, so 1.10 will become 1.1 but I want it to stay as 1.10.


  • 2.  RE: Trying to keep the 0 after a decimal place in a numeric field eg. 1.10 1.20 etc

    Posted 01-05-2018 01:38
    np
    Edit the field properties and set the # of decimals to 2


  • 3.  RE: Trying to keep the 0 after a decimal place in a numeric field eg. 1.10 1.20 etc

    Posted 01-05-2018 01:41
    ... I'm a moron, thank you. I can't believe I overlooked that


  • 4.  RE: Trying to keep the 0 after a decimal place in a numeric field eg. 1.10 1.20 etc

    Posted 01-05-2018 01:42
    :)  Nothing in Quick Base is hard, but there are 1,000 easy things to know.  So you just need to trip 1,000 times once to nail them all.


  • 5.  RE: Trying to keep the 0 after a decimal place in a numeric field eg. 1.10 1.20 etc

    Posted 01-08-2018 19:52
    Similar question. I have it set where it pulls correctly to 2 decimal places on any forms or tables. However, when I try to pull a field into a mailto: it loses the formatting. I saw a previous post of yours recommending using round to solve the problem for cutting it down to 2 points. That solved that problem. Now the only issue is when there is a 1.1 as in above it is losing the 0 and I need it added back.


  • 6.  RE: Trying to keep the 0 after a decimal place in a numeric field eg. 1.10 1.20 etc

    Posted 01-08-2018 22:08
    Right,
    so you will need to convert the number to text with a formula.  I have a small collection of them, but here is one that should work from my notes.

    Substitute in your field name where I have the field [currency field]

    var number Value = Round([currency field],0.01);
    var text Decimals = "." & Right(ToText(Int(Abs($value) * 100)),2);
    var text Thousands = If(Abs($Value)>=1000,ToText(Int(Abs($Value)/1000)));
    var text Hundreds=Right(ToText(Int(Abs($Value))),3);

    If($Value=0,"$0.00",
    IF($Value<0, "-") & "$" & List(",",$Thousands,$Hundreds) & $Decimals)

    Let me know how it goes and if I need to test the formula myself.


  • 7.  RE: Trying to keep the 0 after a decimal place in a numeric field eg. 1.10 1.20 etc

    Posted 06-18-2018 20:32
    what if you need to do this up to the millions, do you just keep adding variables for each digit?


  • 8.  RE: Trying to keep the 0 after a decimal place in a numeric field eg. 1.10 1.20 etc

    Posted 06-18-2018 20:37
    not tested but you woul;d need this extra line

    var text Millions = If(Abs($Value)>=1000000,ToText(Int(Abs($Value)/1000000)));


    and then 

    .....List(",",$Millions, $Thousands,$Hundreds) & $Decimals)


  • 9.  RE: Trying to keep the 0 after a decimal place in a numeric field eg. 1.10 1.20 etc

    Posted 06-18-2018 20:42
    saving my life here! Thank you!


  • 10.  RE: Trying to keep the 0 after a decimal place in a numeric field eg. 1.10 1.20 etc

    Posted 04-26-2018 15:39
    Thanks for the tip. As I needed to display negative values in red, I went with the following approach. I just check how many characters are after the decimal after formatting, then I add back ad is needed.

    var text txtRounded = ToFormattedText(Round([yourvalue]*100,0.01),"none_dot");
    var number wheredot=If(Contains($txtRounded,"."),Length(Right($txtRounded,".")),0);
    var text fmtnbr = If($wheredot = 0, $txtRounded & ".00", If($wheredot = 1, $txtRounded & "0", $txtRounded)) ; 

    If([yourvalue] < 0,  "<span style='color: #EA3C53'>" & $fmtnbr & "</span>",$fmtnbr)


  • 11.  RE: Trying to keep the 0 after a decimal place in a numeric field eg. 1.10 1.20 etc

    Posted 05-09-2019 19:57
    How to format to one place decimal using code from Robert (above)?
    Want to show 00.0%