Calculate inventory

I am trying to use PI to calculate inventory of a product we make.  The product inventory is not stored in any system.  We know how much is made per day and how much we sold per day but not sure how to get the inventory into a tag.  We currently use analysis in AF to calc the amount produced for yesterday and the same for amount sold.  I know inventory is (Yesterdays inv amount + amount produced) - amount sold and I have this in analysis but how do I write this to a tag but keep the yesterday inv amount to use in the next days calculation?

Parents
  • Let's assume there are 3 tags:

     

        Yesterdays inv amount, amount produced and amount sold

     

    Since you already have your formula for the end of day/period inventory:

     

        (Yesterdays inv amount + amount produced) - amount sold

    and you have calculations for amount produced and amount sold, the missing piece seems to be the BEGINNING inventory that is used to seed the rest of the calculations.

    So, create the tags and the analysis and then manually seed the starting value for 'Yesterdays inv amount'; how you determine that value is dependent on your processes.

     

    Then, your end-of-day inventory that will become the new value for 'Yesterdays inv amount' will be:

     

        TagVal('Yesterdays inv amount','*-1d) + 'Amount Produced' - 'Amount Sold'

     

    that value will be written to the scheduled time.

    And that value will be used the next day... moving forward.

Reply
  • Let's assume there are 3 tags:

     

        Yesterdays inv amount, amount produced and amount sold

     

    Since you already have your formula for the end of day/period inventory:

     

        (Yesterdays inv amount + amount produced) - amount sold

    and you have calculations for amount produced and amount sold, the missing piece seems to be the BEGINNING inventory that is used to seed the rest of the calculations.

    So, create the tags and the analysis and then manually seed the starting value for 'Yesterdays inv amount'; how you determine that value is dependent on your processes.

     

    Then, your end-of-day inventory that will become the new value for 'Yesterdays inv amount' will be:

     

        TagVal('Yesterdays inv amount','*-1d) + 'Amount Produced' - 'Amount Sold'

     

    that value will be written to the scheduled time.

    And that value will be used the next day... moving forward.

Children
  • The issue I have is I don't have yesterday inv in a tag.  Right now I have a tag in analysis that for example is (10+tprod)-(tload)  and lets say that =5.  Can I output that to a tag and then use that in place of the 10 (yinv) for the next days analysis?

  • I am still a little confused ...

     

    I have the production tag

    I have the sold tag

     

    I do not have what the yinv is anywhere in the system which is what I need to calculate it.  I know what it is and I can hardcode it in the first analysis but if I take it out and somebody backfills I think it would break?

  • Yes, that is exactly what you need to do, create a yinv tag and populate it.

    Let's assume that you run production and inventory on a clock day which ends at midnight.

    Your analyses may be:

     

    Analysis 1: calculate today's production and output the value to the production tag

     

                      calculate today's sale and output the value to the sold tag

     

                      schedule the calculation to run daily at midnight with the value being written at midnight

     

    Analysis 2: calculate end-of-day inventory as yinv + tprod - tload (as you've stated above)

                       *** yinv will have the ending inventory from the previous day at this point ***

                       schedule the calculation to run periodically at 5 minutes after midnight to ensure the tprod and tload values are available

                       using the 'Advanced' tab to change the output time stamp to 'Relative to trigger time: *-5m'

                       *** this will force the ending inventory to be written at midnight, so the same time as tprod and tload

  • If you have the yinv value, manually enter that value into the yinv tag using PI-SMT Archive Editor, then, the calculation will work from that time forward.

    If you are concerned someone will backfill to a time BEFORE your starting date, configure the analysis to have no output in the time is before your starting date.

    You can make it foolproof, but you can't make it damn foolproof; if someone wants to break it, they will find a way, but they will have to work to do so.