How to remove decimals from results

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bluemoon9
    New Member
    • Oct 2008
    • 56

    #1

    How to remove decimals from results

    I have this code to calcuate the percent:
    %Sale: IIf([n]=0,"demoniator is 0",Format([#Sale]/[n],"Percent"))

    This code works well, but the result of the percentage is 2 decimal (like 59.69%). How can I eliminate the decimal to 0 or 1 (like 59.7%). I tried to just calcuate the rate as RateSale: (#Sale]/[n]), then select format as percent with 1 decimal number in the report template. But when n= 0, it shows as #Error# in report and I do not want this.

    could someone please help?

    thanks,

    bluemoon
  • gershwyn
    New Member
    • Feb 2010
    • 122

    #2
    You can format the percent in the report if you want to, but you'll still need the iif to catch division by zero errors. Or, you can continue your original approach using a custom format string instead of the built-in "Percent" format.
    Code:
    %Sale: Iif([n] = 0, "denominator is zero", Format([#Sale]/[n], "0.0%"))
    %Sale: Iif([n] = 0, "denominator is zero", Format([#Sale]/[n], "0%"))
    Results (#Sale = 16, n = 24):
    Code:
    66.7%
    67%

    Comment

    Working...