Print Page | Close Window

How to calculate percentage in Crystal Report

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=10618
Printed Date: 03 May 2024 at 4:15am


Topic: How to calculate percentage in Crystal Report
Posted By: Jancy
Subject: How to calculate percentage in Crystal Report
Date 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



Replies:
Posted By: Emir_W
Date 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):
( mailto:%7b@totgrp - {@totgrp } / mailto:%7b@totall - {@totall }) * 100
 
 
and put mailto:%7b@totpercentagate - {@totpercentagate } in group footer (GF).
 
 
hope it help.
 


-------------
Emir W


Posted By: DBlank
Date 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


Posted By: Jancy
Date 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


Posted By: Emir_W
Date Posted: 27 Jul 2010 at 1:19am
you can drag n drop both formula ( mailto:%7b@totgrp - {@totgrp } and mailto:%7b@totall - {@totall }) from Group Footer to Group Header section.
 
 
hope it hep.
 
 


-------------
Emir W


Posted By: Jancy
Date 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
 


Posted By: Emir_W
Date 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.
 


-------------
Emir W



Print Page | Close Window