Displaying as a percentage

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Displaying as a percentage

    In my SQL Query I am selecting two fields from an Access database, both of
    which are numbers. I am then dividing the two together and using AS to create a
    new virtual field. The new "Percentages" field is showing the correct answer
    but the answer is in decimals (i.e. .666666) and I need it to be formateed as a
    percentage (i.e. 67%). Is there a way to do this in ColdFusion? Part of my
    SELECT statement is below;

    Evaluations.Total_Points/QuestionSet1.A_Answer_Points AS Percentages (i.e.
    4/6+.666666666)

    Is there a way to refernce the variable #Percentages# and have it displayed as
    a percentage?

    Thanks for your help


    AHT Barry Guest

  2. Similar Questions and Discussions

    1. ok I can do a totals row but how about a percentage row after each data row
      actually I made a totals column a b c d e f total 10 35 55 3 34 35 172 10 25 15 2 10 22 84 but would...
    2. CFCharts and Percentage
      Hello, i got a problem with cfchart and the percent Values. I want to show some numbers I calculated from a query before. Now the numbers are...
    3. Getting an accurate Tax percentage
      Hi Guys Wonder if you can help with my problem that seemed simple enough at first, but now appears to be a real pain. Basically I have created...
    4. format Boundcolumn as Percentage
      I have a datagrid with Boundcolumns. I have a number in the db that represents a percentage. I want the datagrid column to output the percentage...
    5. preloader percentage
      Hi! I am sure my question will seem so basic to you... I?m just getting started with flash If want the typical preloader with a bar getting filled...
  3. #2

    Default Re: Displaying as a percentage

    Yes, you can do calculations and formatting on #Percentages#.
    Something like "#Round (Percentages * 100.0)#%" would work. BUT...

    You may be able to do this much more elegantly in Access.

    Try changing that select snippit to:
    SELECT Format (Evaluations.Total_Points/QuestionSet1.A_Answer_Points, "0%") AS
    Percentages

    Regards,
    -- MikeR


    MikerRoo Guest

  4. #3

    Default Re: Displaying as a percentage

    Minor correction to the last post.

    Round() will work perfectly, if you are interested in whole percents. If you
    may (or want) to have something like: 3.5%, the NumberFormat() is more
    appropriate. NumberFormat() also does requested rounding for you. For example:

    NumberFormat(num*100, "___._") - percent with one decimal.



    Mr Black Guest

  5. #4

    Default Re: Displaying as a percentage

    Mr Black's right if you want to futz around with formatting after the fact.
    NumberFormat() is better than Round() from a code flexibility standpoint.

    However, NumberFormat() isn't half as powerful as Access' Format() function.
    (Format() formats %, for example, NumberFormat() doesn't).

    My point was it is better to format the data the way you want it at the
    beginning (the database), than to clean it up later.
    Cleaning it up later, costs more code and more processing time.

    -- MikeR


    MikerRoo Guest

  6. #5

    Default Re: Displaying as a percentage

    Thanks for the help guys. I tried to use the suggestion for formatting it in
    Access but kept getting a "missing parameter" error. I did howver get it to
    work using the NumberFormat() tag in ColdFusion and it is worknig perfectly!

    Thanks again.

    AHT Barry Guest

  7. #6

    Default Re: Displaying as a percentage

    You got that missing parameter error because of the way CF handles quotes for Access. My bad.
    Change "0%" to '0%' (single quotes) and it will work.

    -- MikeR
    MikerRoo Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139