How to sum a formula with a shared variable in it
Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22282
Printed Date: 02 May 2024 at 8:41pm
Topic: How to sum a formula with a shared variable in it
Posted By: GrisCorp
Subject: How to sum a formula with a shared variable in it
Date 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?
|
Replies:
Posted By: Sastry
Date 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
|
Posted By: GrisCorp
Date 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.
|
|