[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

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;

WhilePrintingRecords;
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}    
//1
else if One
        then {BAQReportResult.JobMtl.TotalCost}
//1a
else if OneA
        then {BAQReportResult.JobMtl.TotalCost}
//2
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}
//2a
else if TwoA
        then {BAQReportResult.PORel.RelQty}/{BAQReportResult.PORel.XRelQty}*{BAQReportResult.PODetail.DocUnitCost}*{BAQReportResult.PORel.RelQty}
//3
else if Three
        then {BAQReportResult.PORel1.RelQty}/{BAQReportResult.PORel1.XRelQty}*{BAQReportResult.PODetail1.DocUnitCost}*{BAQReportResult.JobMtl.RequiredQty}
//3a
else if ThreeA
        then {BAQReportResult.PORel1.RelQty}/{BAQReportResult.PORel1.XRelQty}*{BAQReportResult.PODetail1.DocUnitCost}*{BAQReportResult.PORel1.XRelQty}
//4
//else if  Four
//        then 4
//5
else if Five
        then {BAQReportResult.PORel1.RelQty}/{BAQReportResult.PORel1.XRelQty}*{BAQReportResult.PODetail1.DocUnitCost}* {BAQReportResult.SE-RemainingQty} +
                {BAQReportResult.JobMtl.TotalCost}
else if FiveA
        then {BAQReportResult.PORel1.RelQty}/{BAQReportResult.PORel1.XRelQty}*{BAQReportResult.PODetail1.DocUnitCost}* {BAQReportResult.SE-RemainingQty} +
                {BAQReportResult.JobMtl.TotalCost}
//6
else if Six
        then {BAQReportResult.PORel.RelQty}/{BAQReportResult.PORel.XRelQty}*{BAQReportResult.PODetail.DocUnitCost}* {#XRelQtySum} +
                {BAQReportResult.JobMtl.TotalCost}
//6a
else if SixA
        then {BAQReportResult.PORel.RelQty}/{BAQReportResult.PORel.XRelQty}*{BAQReportResult.PODetail.DocUnitCost}*{BAQReportResult.SE-RemainingQty} +
                {BAQReportResult.JobMtl.TotalCost}
//7
//else if  Seven
//        then 7
//8
else if Eight
        then {BAQReportResult.JobMtl.TotalCost}
//9
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!
0
SeyerIT
Asked:
SeyerIT
  • 3
  • 2
1 Solution
 
mlmccCommented:
You will have to use variables.

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

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

In the report footer
WhilePrintingRecords;
Global NumberVar GrandTotal;
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.

mlmcc
0
 
SeyerITAuthor 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!
0
 
SeyerITAuthor 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)
0
 
mlmccCommented:
Change the reset like this

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

mlmcc
0
 
SeyerITAuthor Commented:
Perfect! Thanks again!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now