Search code examples
crystal-reportsreport

Calculate Percentage of total within group


I have Crystal Report group on year. Within the group I have a distinctcount on emplyee number so I know how many emplyees were terminated within a given year.I also have formulas that I summarize using sum for years of service like lees than 1 year or equal to one year and less than 3 years, etc. I also have a formula that adds 2 of the summary fields together so I can get a total of how many terminations occured with less tha 3 years of service. This all works as it should but when I try to add in a formuaa to get a percent of the total Terminations I get the wrong calculation and the same result displayes in every year despite having different numbers

All summaries are in groupfooter Total Terminations for 2023 65 summary for < 1 year 34 Summary for >=1<3 years 17 formula to add the 2 summeries -

sum({@<1})+ sum({@>=1<3})

formula to get percent of (51/65)

local numbervar Total :=sum({@<3Years});
if Total <> 0 then
Total/distinctcount({Employee.Employee_Number})*100

I put that formula in groupfooter and get 77.71% when 51/65 = 78.46 The output of 78.46 displays on every year, when there should be a different percent represenative of that years numbers.

what should I be doing differently? Thanks in advance


Solution

  • Sure: for a report that groups on {Product_Type.Product Type Name} the sum of a {@value} formula for the current Product Type Name (specified as the 2nd argument) is:

    Sum ({@value}, {Product_Type.Product Type Name})