I am new to FlexSim (experienced with other discrete-event software) and have a very basic knowledge of SQL.
I want to calculate Time-Between-Arrivals (for each PartNum) from a Statistics Collector where all 6 PartNums are in the same table.
In the single PartNum case I used FlexScipt to calculate a field each time the part arrived:
The custom code is
But that doesn't work when all PartNums are in the same table, since it compares the previous arrival regardless of PartNum.
Solution 1: Use a Calculated Table to Filter an individual PartNum. But then I need to do the difference calculation within SQL. Is this possible? (Here using ROW_NUMBER() -1 as a test for creating a calculated column.)
? Is there an SQL command or function that allows me to access an individual field from the previous record so I can do a calculation with it - something like
"Arrival Time (ROW_NUMBER) - Arrival Time (ROW_NUMBER - 1) " ?
? Then how do I deal with the first row where you can't look at a previous row ? Can I use a CASE-WHEN-THEN-ELSE-END clause?
? OR.. Can I use FlexScript again within the Query Box above?
Solution 2: I could just create a separate copy of the Statistics Collector for every PartNum, but that seems to be less efficient and elegant!
Solution 3: I could just export the data to Excel and manipulate it there, but that does not allow me to have a chart within the model that can be updated dynamically to use for validation and warm-up calculation.
Any suggestions?
Thanks!