Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Percentage formula Post Reply Post New Topic
Author Message
QA2Crystal
Newbie
Newbie


Joined: 16 May 2008
Online Status: Offline
Posts: 4
Quote QA2Crystal Replybullet Topic: Percentage formula
     Posted: 16 May 2008 at 11:40am
Hello everyone!
 
This is my first post on the board. 
 
I am trying to enter a percentage field to a report for a specific college campus.  The report is grouped by campus, course, instructor and grade.  I need a percentage field between the grade (a,b,c,d,f) fields.  I have tried this code: Sum ({@a}, {@instr})/DistinctCount ({GPC_GRADE_DISTRIBUTION.STU_PIDM}, {@instr})
 
in the formula field and checked to see if it was right, and it was, but the percentage field didn't show.  Can anyone shed some light on what I'm doing wrong? 
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 17 May 2008 at 3:49pm
Crystal actually has a percentage operator - '\' (instead of '/').  Also, you need to be careful to make sure that the number you're dividing by isn't 0.
 
I would create one formula for the DistinctCount, like this:
 
DistinctCount({GPC_GRADE_DISTRIBUTION.STU_PIDM}, {@instr})
 
Then do this in the formula you show above:
If {@InstructorCount} > 0 then
else 0
 
When I place a percentage on the report, I then format the object to include the percent sign like this:
1.  Right-click on the formula in the report and select "Format..."
2.  Go to the Number tab and select "Custom Format".
3.  Go to the Currency tab (I think that's what it's called... ) and turn on the currency sign.  Change the position in the drop down so that it comes after the number.  Change the currency sign to the percent sign.
4.  Click OK and OK.  You're number is now formatted to include the percent sign.
 
-Dell
IP IP Logged
QA2Crystal
Newbie
Newbie


Joined: 16 May 2008
Online Status: Offline
Posts: 4
Quote QA2Crystal Replybullet Posted: 20 May 2008 at 7:14am
Well, I have a similar formula to calculate the numbers of A's, B's, C's etc. which looks like this: if {GPC_GRADE_DISTRIBUTION.FINAL_GRADE} like 'A*'
then tonumber(1)
else tonumber(0)
I'll try your percentage formula in the a% field to see if I can get it to work. 
IP IP Logged
QA2Crystal
Newbie
Newbie


Joined: 16 May 2008
Online Status: Offline
Posts: 4
Quote QA2Crystal Replybullet Posted: 20 May 2008 at 7:23am
I'm gonna try your suggestion.  I'm multiplying the formula by 100 to get the percentage.  Would I place the 100 at the end of the forumla you suggested?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 20 May 2008 at 10:55am
You don't need to multiply by 100 - if you use '\' instead of '/' it will automatically calculate it as a percent rather than as a decimal.
 
-Dell
IP IP Logged
QA2Crystal
Newbie
Newbie


Joined: 16 May 2008
Online Status: Offline
Posts: 4
Quote QA2Crystal Replybullet Posted: 22 May 2008 at 5:45am
Okay, great.  I have finally gotten that problem taken care of but now, I have another.  I have put the percentage columns next to the grades but am having a problem with the percentage totals reflecting the next grade instead of the percentage. 
 
Say I have columns:
 
                 A  A%  B  B%  C
                 2  1.3  4  2.3   5
Total:        2  4     4  5
 
It's coming out like this...how can I correct it?  
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum