Need to Grand Total a Running total in Crystal

I think this is probably more complicated than it sounds in the title but here goes..

To try and start from the top, I have created a running total for an Order Quantity which shows up in my detail section. Because I have some duplicates that show up in my detail section I had to create a formula within the running total which reads;

Not(Not OnFirstRecord
And {BAQReportResult.JobMtl.AssemblySeq} = Previous({BAQReportResult.JobMtl.AssemblySeq})
And {BAQReportResult.JobMtl.PartNum} = Previous({BAQReportResult.JobMtl.PartNum})
And {BAQReportResult.PORel.PORelNum} = Previous({BAQReportResult.PORel.PORelNum}))

This Formula is called XRelQtySum.
So to sum this one up, it basically adds up all the order quantites for a particular part and skips the duplicate entries.

Next, using the XRelQtySum Running total, I have another rather complex formula that gives me the CurrentCost for the Part and it uses the XRelQtySum in some sections of the formula. The CurrentCost formula looks like;

Global BooleanVar Rework;
Global BooleanVar One;
Global BooleanVar OneA;
Global BooleanVar Two;
Global BooleanVar TwoA;
Global BooleanVar Three;
Global BooleanVar ThreeA;
Global BooleanVar Four;
Global BooleanVar Five;
Global BooleanVar FiveA;
Global BooleanVar Six;
Global BooleanVar SixA;
Global BooleanVar Seven;
Global BooleanVar Eight;
Global BooleanVar Nine;
if      Rework
        then {BAQReportResult.JobMtl.TotalCost}    
else if One
        then {BAQReportResult.JobMtl.TotalCost}
else if OneA
        then {BAQReportResult.JobMtl.TotalCost}
else if  Two then
    if {BAQReportResult.PORel.RelQty} = 0 or {BAQReportResult.PORel.XRelQty} = 0
        then 0
        else {BAQReportResult.PORel.RelQty}/{BAQReportResult.PORel.XRelQty}*{BAQReportResult.PODetail.DocUnitCost}*{BAQReportResult.PORel.RelQty}
else if TwoA
        then {BAQReportResult.PORel.RelQty}/{BAQReportResult.PORel.XRelQty}*{BAQReportResult.PODetail.DocUnitCost}*{BAQReportResult.PORel.RelQty}
else if Three
        then {BAQReportResult.PORel1.RelQty}/{BAQReportResult.PORel1.XRelQty}*{BAQReportResult.PODetail1.DocUnitCost}*{BAQReportResult.JobMtl.RequiredQty}
else if ThreeA
        then {BAQReportResult.PORel1.RelQty}/{BAQReportResult.PORel1.XRelQty}*{BAQReportResult.PODetail1.DocUnitCost}*{BAQReportResult.PORel1.XRelQty}
//else if  Four
//        then 4
else if Five
        then {BAQReportResult.PORel1.RelQty}/{BAQReportResult.PORel1.XRelQty}*{BAQReportResult.PODetail1.DocUnitCost}* {BAQReportResult.SE-RemainingQty} +
else if FiveA
        then {BAQReportResult.PORel1.RelQty}/{BAQReportResult.PORel1.XRelQty}*{BAQReportResult.PODetail1.DocUnitCost}* {BAQReportResult.SE-RemainingQty} +
else if Six
        then {BAQReportResult.PORel.RelQty}/{BAQReportResult.PORel.XRelQty}*{BAQReportResult.PODetail.DocUnitCost}* {#XRelQtySum} +
else if SixA
        then {BAQReportResult.PORel.RelQty}/{BAQReportResult.PORel.XRelQty}*{BAQReportResult.PODetail.DocUnitCost}*{BAQReportResult.SE-RemainingQty} +
//else if  Seven
//        then 7
else if Eight
        then {BAQReportResult.JobMtl.TotalCost}
else if Nine
        then {BAQReportResult.JobMtl.TotalCost}
else 0

The formula takes into account nine different variables which determines how the CurrentCost needs to be achieved.

So I have this CurrentCost which give me each materials current cost. All the materials are grouped into Jobs. Now I need to get a total of CurrentCost in the Jobs Footer. Crystal is not allowing me to select my CurrentCost formula to place in either a running total or a sum though.
So back to my original question, How or Can I create Grand or sub Totals of my CurrentCost Formula based on the scenario I have?

Thanks for any help you can provide as well as all the help I have received so far! You guys are great!
Jarred MeyerProduction ManagerAsked:
Who is Participating?
mlmccConnect With a Mentor Commented:
You will have to use variables.

Grand Total
In the report header add a formula to declare the variables
Global NumberVar GrandTotal;

Where you calculate the value
Global NumberVar GrandTotal;
GrandTotal := GrandTotal + {@YourFormula};

In the report footer
Global NumberVar GrandTotal;

If you want group totals you can add a GroupTotal variable.  Set it to 0 in the group header
Change the totaling formula to calculate it.

Jarred MeyerProduction ManagerAuthor Commented:
Ah! I got it! Makes more since now and I didn't have to change any of my existing formulas either like I thought I was going to need to do! The Variables seem to work regardless of what you have used in existing formulas.. Very nice!

Thanks a bunch!
Jarred MeyerProduction ManagerAuthor Commented:
Oh.. I see one slight issue.. Is there a way to get the Variables to reset at the beginning of each group but not reset at a page break?.. (I currently have the group names to repeat on each page and that seems to reset the variable)
Change the reset like this

Global NumberVar GroupTotal;
If Not InRepeatedGroupHeader then
   GroupTotal := 0;

Jarred MeyerProduction ManagerAuthor Commented:
Perfect! Thanks again!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.