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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating a Running Total

Status
Not open for further replies.

BradCustom

IS-IT--Management
Oct 5, 2007
296
US
Hi,

I need some help with a running total. Below is the description of the report and formulas being used.
I'm trying to calculate the remaining inventory balance by subtracting the Order Qty for each detail line.

The Main Report has three groups:
Order_Date
Sales Order
Material

There are two Subreports: first is InProdQty (In Production Quantity) and second is OnHandQty (On Hand Quantity). I've passed the total of each to the main report using the following formulas. Both subreports are linked to the Main Report by the Material field.

"InProdQty"
Code:
whileprintingrecords;
shared numbervar InProdQty :={@InProdQty}

"OnHandQty"
Code:
whileprintingrecords;
shared numbervar onhandqty :=Sum ({Material_Location.On_Hand_Qty}, {Material_Location.Material})

Both passed variables display fine on the Main Report. On the Main Report I have the following formula to find the Total Available.

"TotInvAvailable"
Code:
{@PassInProdQty}+{@PassOnHandQty}

Next I tried using two formulas that I've used in the past for a similar problem but I'm obviously doing something wrong.

First is the variable:
"VarLineQty"
Code:
whileprintingrecords;
numbervar sumline := sumline - {SO_Detail.Order_Qty}

Second formula:
"display"
Code:
whileprintingrecords;
numbervar sumline;

What I'd like to do is a running total where the Order Quantity is subtracted from "TotInvAvailable" which would show the remaining inventory. I'd also like to reset the running total on the Material Group. I'm not sure how this will work because of the group order; 1st Date, 2nd Sales Order, 3rd Material.

Because this report is sorted by Date first you could have material "123" as the first record, the 12th record and the 18th record. Record placement is of course dictated by the Order Date. I'm not sure if this will cause a problem for the running total but I thought I'd mention it.

Thanks you all your help!!
 
FYI

This question relates to a report created with Crystal Reports 2008.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top