Ask a Question related to Macromedia ColdFusion, Design and Development.
-
AHT Barry #1
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
-
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... -
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... -
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... -
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... -
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... -
MikerRoo #2
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
-
Mr Black #3
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
-
MikerRoo #4
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
-
AHT Barry #5
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
-
MikerRoo #6
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



Reply With Quote

