Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: How to sum a formula with a shared variable in it Post Reply Post New Topic
Author Message
GrisCorp
Groupie
Groupie
Avatar

Joined: 08 Mar 2013
Online Status: Offline
Posts: 64
Quote GrisCorp Replybullet Topic: How to sum a formula with a shared variable in it
    Posted: 31 Mar 2017 at 5:52am
I am using Crystal Reports 2011.

I have a report with a subreport.  I have a shared variable that passes last year's item price from the subreport to the main report.  I then have a formula that subtracts that shared variable from this year's price to give me the difference between the two.

I have another formula that then takes that difference and multiplies it by the quantity ordered this year to give me a gross revenue increase.

I am running into a problem trying to summarize the gross revenue increases; the formula that calculates the increase is not available in the dropdown list when I try to create a summary.

Here are the formulas and their locations:
@Difference (not on the report canvas)-
{Invoice.PRICE} - {@Prior Year Price Shared}


Main Report:
Group Footer 3a:
@PriorYearPrice Shared-
WhilePrintingRecords;
Shared NumberVar PriorYearPrice;
PriorYearPrice


Group Footer 3b:
@Revenue Increase-
If {@Difference} = 0
then
0
else
Sum ({Invoice.SHIPQTY}, {Invoice.PRTNUM}) * {@Difference}

Subreport:
Group Footer 2
PriorYearPrice Shared-
WhilePrintingRecords;
Shared NumberVar PriorYearPrice:= {Invoice.PRICE}

How can I summarize the individual Revenue Increases as a Grand Total in the Report Footer?
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 04 Apr 2017 at 5:24am
HI

You need to create two formulas to get this summary :

@init
Whileprintingrecords;
Numbervar x:=x+@Revenue Increase;

// Place the above formula in Group footer 3b

@disp
Whileprintingrecords;
Numbervar x;

// place the above formula in group footer to get summary.

Thanks,
Sastry
Thanks,
Sastry
IP IP Logged
GrisCorp
Groupie
Groupie
Avatar

Joined: 08 Mar 2013
Online Status: Offline
Posts: 64
Quote GrisCorp Replybullet Posted: 04 Apr 2017 at 7:19am
Sastry,

That did the trick!  Thank you ever so much!  You've made my CEO a happy man.
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.032 seconds.