Is there an easy way to format percentage?

josephdeweyjosephdewey Member Posts: 87
What's the best way to format percentage with a Decimal in NAV? I wasn't able to find a good way and keep my variable, TaxPercentage as a Decimal (which I would have preferred). So, I converted it to text using this code:
TaxPercentage := STRSUBSTNO('%1%',ROUND(TotTaxAmount/AmountExclInvDisc*100,2));
Is there a simpler way of doing this? Thanks!
Joseph Dewey
Microsoft Dynamics NAV User

Comments

  • vaprogvaprog Member Posts: 1,139
    You may set the Format property to
    <Precision,0:2><Standard Format,0>%
    
    and SourceExpr to TotTaxAmount/AmountExclInvDisc*100
    If you need it as a string use
    FORMAT(TotTaxAmount/AmountExclInvDisc*100,0,'<Precision,0:2><Standard Format,0>%');
    

    Are you sure about your ROUND expression? Did you mean ,0.01) instead of ,2)?
  • josephdeweyjosephdewey Member Posts: 87
    Hi vaprog,

    Thanks very much for your detailed reply! Your way is much simpler, plus I didn't like my way of keeping numbers as text, in case I need to reuse them in thu future. I didn't understand how to mix formatting with strings, so your explanation helped a lot.

    And you're right about ROUND with what I'm trying to accomplish. Thanks very much for pointing that out. I guess I'm too used to Excel.

    Thanks again!
    Joseph Dewey
    Microsoft Dynamics NAV User
Sign In or Register to comment.