Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: How to calculate percentage in Crystal Report Post Reply Post New Topic
Author Message
Jancy
Newbie
Newbie


Joined: 22 Jul 2010
Online Status: Offline
Posts: 4
Quote Jancy Replybullet Topic: How to calculate percentage in Crystal Report
    Posted: 22 Jul 2010 at 7:38pm
hi,
 
In my report i need to calculate percentage of each group. How to write formula to calculate percentage like below mention.
Eg:
 
    Name       Subjects    Marks  Percentage
 
    John         English      100
                     Maths        50
                     Science      50   
                     Total A      200       (Total A/ Total A + Total B) * 100
 
 
     Klin           English      50
                     Maths        50
                     Science      50
   
                     Total  B        150   (Total B/ Total A + Total B) * 100
 
Please help me to write a formula for this.
 
Thanks in advance
Jancy


Edited by Jancy - 22 Jul 2010 at 7:42pm
IP IP Logged
Emir_W
Senior Member
Senior Member
Avatar

Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
Quote Emir_W Replybullet Posted: 23 Jul 2010 at 3:11am
i assume you've grouped the report based on the name.
so, you can create some formulas to calculate it.
 
formula to calculate 'mark' per group (@totgrp):
sum({tbl.mark},{tbl.name})
 
formula to calculate for all (@totall):
sum({tbl.mark})
 
then calculate the total that you request (@totpercentage):
({@totgrp} / {@totall}) * 100
 
 
and put {@totpercentagate} in group footer (GF).
 
 
hope it help.
 
Emir W
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Jul 2010 at 4:28am
also assuming you grouped on name you can also use an insert summary
click on the insert summary button (sigma sign )
select the 'Percentage' value field
Select to reset at the group level
change the last option to show as a percentage of the whole
IP IP Logged
Jancy
Newbie
Newbie


Joined: 22 Jul 2010
Online Status: Offline
Posts: 4
Quote Jancy Replybullet Posted: 27 Jul 2010 at 12:56am
hi,
 
this formula is working if we have both @totgrp and @total are same section.
 
Here @totgrp is displays in Groupheader footer and @total we are putting in report footer.
 
so we i apply formula like this it is not getting @total. What we do for this
IP IP Logged
Emir_W
Senior Member
Senior Member
Avatar

Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
Quote Emir_W Replybullet Posted: 27 Jul 2010 at 1:19am
you can drag n drop both formula ({@totgrp} and {@totall}) from Group Footer to Group Header section.
 
 
hope it hep.
 
 


Edited by Emir_W - 27 Jul 2010 at 1:25am
Emir W
IP IP Logged
Jancy
Newbie
Newbie


Joined: 22 Jul 2010
Online Status: Offline
Posts: 4
Quote Jancy Replybullet Posted: 27 Jul 2010 at 1:40am

Hi emir,

 
@total is the running total of each student. If i drag and drop that will show individual student total.
 
like
 
Name       Subjects    Marks  Percentage
 
    John         English      100
                     Maths        50
                     Science      50   
     Total A      200                (Total A/ Total A + Total B) * 100
    @total=200
 
     Klin           English      50
                     Maths        50
                     Science      50
   
                     Total  B        150   (Total B/ Total A + Total B) * 100
     @total=350
 
IP IP Logged
Emir_W
Senior Member
Senior Member
Avatar

Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
Quote Emir_W Replybullet Posted: 27 Jul 2010 at 2:28am
i'm creating a report using your data and here is my result.
 
before drag n drop to Group Header:
---------------------------------------------
          name          subject             mark        percentage
john
          john            english             100
          john            math                  50
          john            science               50
   total john:                                200            50.63
 
klin
          klin            english               50
          klin            math                  72
          klin            science               73
   total klin:                                  195            49.37
 
Grand Total                                 395
 
=============================================
after drag n drop to Group Header:
---------------------------------------------
          name          subject             mark        percentage
john                                              200          50.63
          john            english             100
          john            math                  50
          john            science               50
 
 
klin                                              195            49.37
          klin            english               50
          klin            math                  72
          klin            science               73
 
Grand Total                                 395
 
 
 
hope it help.
 


Edited by Emir_W - 27 Jul 2010 at 2:29am
Emir W
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.047 seconds.