Get last entry from StatisticsCollector table

Get last entry from StatisticsCollector table

guiroehe
Collaborator Collaborator
425 Views
3 Replies
Message 1 of 4

Get last entry from StatisticsCollector table

guiroehe
Collaborator
Collaborator

Hello,

I wonder if there is a way to make a CalculatedTable subset only the last entry on from a StatisticsCollector table.

Apparently, LAST is not a valid command in FlexSim's SQL engine.

If that is not possible, how one can create a repeating event that updates a single row on a statistics collector?

Thank you.

0 Likes
Accepted solutions (1)
426 Views
3 Replies
Replies (3)
Message 2 of 4

joerg_vogel_HsH
Mentor
Mentor

You get Number of Rows by clause COUNT or last entry by ORDER BY of index or time? If a language interface does not support a function, then you can still try to get to similar result on a longer way. More interesting is a question is there event that occurs if a new entry increases number of rows in a table. Otherwise you check if a  event happens that will update a calculated table. Or as you suggested you update a calculated table upon a time interval.

0 Likes
Message 3 of 4

FelixMoehlmann
Mentor
Mentor
Accepted solution

You can use "SELECT LAST_VALUE(columnName) FROM tableName" or "SELECT columnName FROM tableName ORDER BY ROW_NUMBER DESC LIMIT 1".

https://docs.flexsim.com/en/24.2/Reference/DeveloperAdvancedUser/SQLQueries/SQLQueries.html#language

 

To update a single row in a Statistics Collector, always use the same row value for each event and don't finish the row. In the columns tab set all events to update the eligible columns and make sure that those columns use the "Event Value" field for the data rather than the "Row Add Value".

Message 4 of 4

guiroehe
Collaborator
Collaborator

Thank you, @FelixMoehlmann ,

I had tried the single row statistics collector before, but I had the columns "Update Timing" property configured to "When the value is assessed". That was causing an error and the table was populated with null, even using the "Event Value" field configured. Changing the "Update Timing" to "When the row is added and/or updated by events" allowed me to connect the columns to the events and it worked as expected.
Thank you.

0 Likes