Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Juggernaut

Stock Pricing Average Possible?

Featured Replies

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

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.

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 ) )

)

  • Author

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

  • Author

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

Here's a working demo, with comments added to the calculation.

AverageLastN.fp7.zip

  • Author

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 :-)

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.