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

Average Calculation 1

Status
Not open for further replies.

abbasaif

ISP
Oct 8, 2018
89
AE
Hi,

How can I calculate the moving average value of a particular item which purchased multiple times.

Please let me have some idea how to calculate the figure in Red.
The Arrow mark shows the field name.

Thanks

Abbassaif

I want to attach excel file. How can I do so?

avg_zklmql.jpg
 
The calculation of a moving average is exactly the same as the calculation of any other average. You take the most recent N values of the figure in question, find the sum, and divide by N. In this case, N would be the number of periods over which you want to calculate the average.

But surely already know this. I suspect that, as usual, there is more to this problem that is indicated in the question.

And you mention in passing that you want to "attach" an Excel file (whatever that means). This is a completely separate issue, and should be posted in a separate thread, preferably with a title that indicates the nature of the question.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mr. Mike for the reply!

And you mention in passing that you want to "attach" an Excel file (whatever that means). This is a completely separate issue, and should be posted in a separate thread, preferably with a title that indicates the nature of the question.

No, No I want to attach that excel file which is shown in image, just to check the formula for your reference and which I want to apply in my program.

Can I derived it from SQL Syntax.

Thanks

Abbassaif
 
In an attempt to keep this thread focused, can we concentrate on the original question. I wrote:

Mike said:
The calculation of a moving average is exactly the same as the calculation of any other average. You take the most recent N values of the figure in question, find the sum, and divide by N. In this case, N would be the number of periods over which you want to calculate the average.

Is there anything in that that you don't understand?

Mike





__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Previously there were N number of items and the total cost was TOTAL_VALUE. So,
AVG_PRICE = TOTAL_VALUE / N

Then, M units have been issued out. So the value of the remaining units is
BALANCE_VALUE = TOTAL_VALUE - (M * AVG_PRICE)
BALANCE_STOCK = N - M

Next, again there is a new purchase N1 number of items for a total cost of NEW_ORDER_COST. Now the total value of the stock is
CURRENT_COST = BALANCE_VALUE + NEW_ORDER_COST.
CURRENT_STOCK = BALANCE_STOCK + N1

And the new average cost of per unit is
NEW_AVG = CURRENT_COST / CURRENT_STOCK

That's my understanding.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top