Thanu
Thanu

Reputation: 2501

How to add a conditional grand total in Crystal Reports?

I have a group running total that needs to be sum up at the report footer. Since thats not possible with CR I had to end up having another running total that refreshes "Never". But now I need to calculate some percentages at the group level based on this Grand total. Unfortunately I cannot access the value for grand total (because its another running total). Confused?? Ok reports should look like below..


    Column 1                           | Colunm 2
    ========                            ========= 

| Group 200 (Running Total Refresh at Group level) | 20% (200%1000) |
| Group 500 (Running Total Refresh at Group level) | 50% (500%1000) |
| Group 300 (Running Total Refresh at Group level) | 30% (300%1000) |


Footer 1000 (Running Total Never Refreshed)


But column 2 doesn't give me the correct value. it gives me 100% always means 200%200 or 500%500 etc.

Any idea how to fix this??

Upvotes: 0

Views: 10193

Answers (3)

Lee Tickett
Lee Tickett

Reputation: 6027

I should think your report total wants to simply be a summary field not a running total. Then your column 2 value can be calculated using running total / sum(field);

Here is an example:

  • I have two columns age and salary.
  • When age > 18 i want to add the salary.

Initially I used a running total with a condition {age} > 18

That didn't work well so i deleted the running total, and created a formula: if {age} > 18 then {salary} else 0

I then created a summary on that formula field.

Make sense?

Upvotes: 0

Thanu
Thanu

Reputation: 2501

Thanx Lee, using a running total formula worked, I added following formula to the report footer,

numbervar Samples; 
if {product.sku}="card-sample" then 
   Samples := Samples + {@num_qty}; 

Samples; 

Then I use this formula to calculate column 2

Upvotes: 1

Asif
Asif

Reputation: 2677

Try this

Add a formula field for group percentage and then paste below code in it.

Group total / sum(column)

place this formula at your group level.

Upvotes: 0

Related Questions