snowmanapril
asked on
How to calculate percentage where subtotal figure/grandtotal figure
Dear All,
I use running total expert and I can get subtotal and grandtotal in perfect way.
Previously I was using insert summary as grand total , found out it is incorrect after performing a TOP 10 sort.
Now in my report, I suppress report details section, and I have shown the group name subtotal figure in group footer.
How do I display percentage of figure as well? meaning I need to do this subtotal/grandtotal.
But I wonder how to get grandtotal inside the group footer?
Have been trying hard but still cant figure out how to do it.
I use running total expert and I can get subtotal and grandtotal in perfect way.
Previously I was using insert summary as grand total , found out it is incorrect after performing a TOP 10 sort.
Now in my report, I suppress report details section, and I have shown the group name subtotal figure in group footer.
How do I display percentage of figure as well? meaning I need to do this subtotal/grandtotal.
But I wonder how to get grandtotal inside the group footer?
Have been trying hard but still cant figure out how to do it.
ASKER
I tried already
Cant display the correct data.
Subtotal Percentage=100
Category 1
Category 2
Cant display the correct data.
Subtotal Percentage=100
Category 1
Category 2
ASKER
Sorry accidentally submit the comment
I use the formula you have suggested and place it together with grp footer.
Doesn't work :(
if isnull({#CampaignSubtotal} ) = true or {#CampaignSubtotal} = 0 then 0
else
//({#CampaignSubtotal}/{#C ampaignTot al}) *100
({#CampaignSubtotal}/{#Cam paignTotal }) *100
Subtotal Percentage
Category1 73 100
Catefory2 15 17.05
.......
Total = 133
I use the formula you have suggested and place it together with grp footer.
Doesn't work :(
if isnull({#CampaignSubtotal}
else
//({#CampaignSubtotal}/{#C
({#CampaignSubtotal}/{#Cam
Subtotal Percentage
Category1 73 100
Catefory2 15 17.05
.......
Total = 133
Just out of curiousity what happen if you uncomment this line ({#CampaignSubtotal}/{#Cam paignTotal }) *100
what are the totals?
what are the totals?
ASKER
is the same.
stil showing 100 percentage
stil showing 100 percentage
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah I dun know sub report Oppss :(
New to crystal, so sorry :(
New to crystal, so sorry :(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The problem you're running into is that the running total is only incremented at the same time as the subtotal. In your example for category 1 the total is only 73 at the time of evaluation so you're getting (73/73)*100.
You might want to try this: ({#CampaignSubtotal}/Sum({ WhateverYo urField})) *100
I can't test it, but I think that may use the grand total instead of the running total - which is what you need. Otherwise, I can talk you through subreports & shared variables but that's going to be a lot more work if you aren't familiar with them.
frodoman
You might want to try this: ({#CampaignSubtotal}/Sum({
I can't test it, but I think that may use the grand total instead of the running total - which is what you need. Otherwise, I can talk you through subreports & shared variables but that's going to be a lot more work if you aren't familiar with them.
frodoman
ASKER
Hi frodoman,
I cant use grandtotal summary as when i involve TOP 10 this criteria, the grandtotal is incorrect, thats y i use running total instead
I cant use grandtotal summary as when i involve TOP 10 this criteria, the grandtotal is incorrect, thats y i use running total instead
Is there a reason why you are using a running total rather than a group with a sum or count of rows?
ASKER
I refer to this http://www.crystalconsulting.ca/faq.html
3. Why are my grand total and/or summaries incorrect after performing a
group selection or Top N/Bottom N sort?
Answer: While record selection is evaluated during the first pass, group
selection is evaluated in the second pass. Because Crystal Reports creates
summaries in the first pass (therefore prior to evaluating group
selection), the summaries don't reflect the groups that have been
suppressed from the report.
To correctly summarize and/or grand total a report that has a group
selection formula, creating running totals, either using variables and the
WhilePrintingRecords function, or with the Running Total Expert (available
only with version 7 and 8).
3. Why are my grand total and/or summaries incorrect after performing a
group selection or Top N/Bottom N sort?
Answer: While record selection is evaluated during the first pass, group
selection is evaluated in the second pass. Because Crystal Reports creates
summaries in the first pass (therefore prior to evaluating group
selection), the summaries don't reflect the groups that have been
suppressed from the report.
To correctly summarize and/or grand total a report that has a group
selection formula, creating running totals, either using variables and the
WhilePrintingRecords function, or with the Running Total Expert (available
only with version 7 and 8).
ASKER
I encounter divison by zero error when i using sub report method
I have selection criteria in Main report
{Incident.Campaign Name} <> "NULL" and
{Incident.Group Name} = "HELP" and
{Incident.Open Date & Time} In {?FDate} To {?FTDate}
Do I need to include all this in subreport as well?
What field shld be link between main and subreport?
where shld i put my subreport? at report header?
I have selection criteria in Main report
{Incident.Campaign Name} <> "NULL" and
{Incident.Group Name} = "HELP" and
{Incident.Open Date & Time} In {?FDate} To {?FTDate}
Do I need to include all this in subreport as well?
What field shld be link between main and subreport?
where shld i put my subreport? at report header?
Your selection criteria for the subreport should be identical to the main report - otherwise you won't be counting the same number of records/values. There should not be any link between the subreport - it's purpose is only to total the values so there isn't a need for a link - just place the subreport in your report header.
The division by zero may be a problem with how you're populating the variable.
The division by zero may be a problem with how you're populating the variable.
ASKER
Hi Frodoman,
I place it at sub report header, the grandtotal has division zero error, but when i place at subreport footer it works!
However, the total percentage of top 10 data does not = 100% (Due to rounding I guess).
So when I manually calculate is 100.01%.
Any kind of method can make the top 10 category total percentage is 100?
Thanks.
I place it at sub report header, the grandtotal has division zero error, but when i place at subreport footer it works!
However, the total percentage of top 10 data does not = 100% (Due to rounding I guess).
So when I manually calculate is 100.01%.
Any kind of method can make the top 10 category total percentage is 100?
Thanks.
I'm certain it is due to rounding. You could probably make it equal or at least closer to 100% simply be expanding the number of decimal places being shown so (for example) the value 20.25% might actually appear as 20.2386% -- it's up to you whether that is important or not for your specific report.
If I understood correctly, you have it working now other than the rounding, right?
If I understood correctly, you have it working now other than the rounding, right?
ASKER
Yup.
I got it workable by using subreport.
Kind of strange, if i did not use top 10, no need to use subreport i can calculate percentage based on grandtotal.
I got it workable by using subreport.
Kind of strange, if i did not use top 10, no need to use subreport i can calculate percentage based on grandtotal.
if isnull(#subtotal) = true or #subtotal = 0 then 0
else
(#grandtotal/#subtotal) *100
* you may need to switch them around, never was good at checks for division and for that matter coding out division.