Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 6557 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

Hi All, is it possible to calculate the average price from the last three purchase orders for a stock item?

I'm just not sure how to obtain and evaluate just the last three prices.

Additionally some low use items may only have one price recorded for that item which makes it a bit harder.

Thanks Peter :-)

Edited by Guest
Posted

Well if your PO has a related line items table between the products and the PO, you can from the products side make a relationship sorted by date Descending. Then you can use an Unstored calc of:

cLastThree [repeating calc of 3 reps] =

GetNthRecord ( Extend ( ProducttoLineItem::price ); Get ( CalculationRepetitionNumber ) )

ProdAvg = Average ( cLastThree )

In regards to what you mentioned as "low use items" having only one price, it is okay because an average of only one number is the number.

Posted

You could just as easily get them from the other end (i.e. without forced sorting):

Let ( [

n = 3 ;

m = Count ( Child::ParentID ) ;

i = Get ( CalculationRepetitionNumber ) 

] ; 

Case ( i ≤ Min ( 3 ; m)  ; GetNthRecord ( Extend ( Child::Value ) ; m - i + 1 ) )

)

Posted (edited)

Thanks for the ideas, I'll try them and see how I go.

The individual purchase order line items use the StockID as a secondary key so are related to the Stock Items.

Thanks Peter :-)

Edited by Guest
Posted (edited)

Hi Comment, I've tried using your suggestion but it seems to only evaluate the last P/O Line Item record created for each stock item?

I've tried to figure out why this is but I'm not very familiar with some of the functions used. Could you post a small explanation about each step so I can learn from this?

Thanks Peter :-)

Edited by Guest
Posted

Many Thanks Comment, it turned out that I only had one repetition specified on the main calculation field so it only showed the most recent value.

Cheers Peter :-)

This topic is 6557 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.