Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Sum in Group Footer with Shared Variables passed from subreport

Status
Not open for further replies.

Michael6835

IS-IT--Management
Sep 26, 2012
1
US
Hello All:
I am fairly new to Crystal Reports (2008). My company just recently asked me to reproduce a P/L report from our "new" system so that it matched what we got from our "old" system.

The report criteria contained numerous one to many relationships that i had to sum on some lever by customer. I decided on using subreports and shared variables to do the trick.
The issue i have now is I need to perform calculations based on criteria in another columnn. I have included an example of the portion of the report i am currently struggling with.
We are a bus company and thus have different vehicle types. The reports groups all charters by customer and displays information such as "revenue", payroll", and other profit and cost columns which are based on formulas on the fields below.

Actual Miles and type are being passed from subreports. We have 2 vehicle types, "Full" and "mini" The "Other Direct" column is supposed to take the "actual miles" and multiply that times a "budgeted" number. In our case we're using examples of .80 for mini and 1.25 for full.
I have been able to accomplish this on the detail level of the main report by specifying an if statement in the other direct formula.
If {type} = "mini" Then @miles * .8 else @miles * 1.25.
I need to be able to some this "other direct" column to reflect this difference in calculations. Currently my report works if i only use one flat rate. I have tried creating 2 separate variables "mini" and "full" and using if statements in the subreport. Then tried to specify @OrderDirect2 (footer) to be "mini" + "full". But it never works out. When placing the two formulas on the group footer (and resets in the header) I am getting mixed results. For example, if I only have a customer with all "full" or all "minis" charters it works. If i come across a customer that contains mixed orders, then only one variable is set and the other is 0.
apologies for the long explanation, hoping the detail will reveal somethign simple i am missing.
Thanks
Mike

Group 1 Customer ABC
Charter ID "Actual Miles" Other Direct type(not actually displayed on report, but passed from "subreport" so if statement can be used)
1 500 $625 full
2 500 $400 Mini

Group 1 Footer 1000 $1025
 
to pass data from a subreport to a main report:

1. the subreport has to be before the place the data in the main report it will be used. For example, the subreport in in Group header 1A and you use it in Group header 1B.

2. each data element you pass must be a shared variable. SHARED NUMBERVAR MINI
In the report footer of your subreport you would include a formula that would assign the final value to the variable
MINI := {@mini count}

3. In the main report you create a formula that contains the same shared variable. SHARED NUMBERVAR MINI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top