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

Substract

Status
Not open for further replies.

mariaor

Technical User
Jul 19, 2010
6
MX
Hi there, I have a table that looks like this:

Month Sales Change
January 1999 2,536
Februrary 1999 5,431
March 1999 7,299
April 1999 6,542

And so on. I need to calculate using Visual Fox Pro, the change between January and February (5,432- 2536), between February and March, between March and April....
Any suggestions?
Thanks
 
You have to SCAN through the table saving off the first amount, then move to the next record and subtract the saved amount from the current amount. Something like:
Code:
DO WHILE !EOF()
   SCATTER NAME oPrior
   SKIP 
   SCATTER NAME oCurrent
   
   STORE oCurrent.sales - oPrior.sales TO m.nInDiff 
   REPLACE change WITH m.nInDiff   
ENDDO


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top