question

Jeremy R avatar image
0 Likes"
Jeremy R asked Jeremy R commented

Export Performance Measures Table to CSV

Is there a way to export a Performance Measures Table to a CSV? For Global Tables, Calculated Tables, and Statistics Collectors, I can use the command exporttable. However, this does not work for Performance Measures Tables.

I can export Performance Measures Tables using the Excel Export interface, but this can only write to pre-existing Excel documents. I want to be able to export the contents of my Performance Measures Table to a CSV file.

FlexSim 21.2.2
performance measuresexportcsvperformance measures table
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Brittany Evans avatar image
0 Likes"
Brittany Evans answered Jeremy R commented

@Jeremy R ,

Since how Performance Measures are constructed a little different than traditional tables you have to do things a little differently to be able to export them using the exporttable command. I have attached a sample model that has a script in it that properly exports a Performance Measure Table.

Initially I tried to just run the exporttable command on the performanceMeasures variable node for the Performance Measure, but this only partially worked because it would export everything correctly except the value was a reference to the statistic you were interested in; not the current value. From there, a different approach was needed which ended up working. Essentially, you have to get access to the performanceMeasures variable node and run it through a query that gets dumped into a dummy node, which can then be exported using the exporttable command. (See Code Below)

//Get Access to the performanceMeasures variable node for the Performance Measure you want to Export
treenode export = getvarnode(Model.find("Tools/PerformanceMeasureTables/PerformanceMeasures"), "performanceMeasures");

//Create a Dummy Dump location for the data
treenode dump = Model.find("Tools").subnodes.assert("dump");
dump.subnodes.clear();

//Run a query that will get you the correct table with the current values that is dumped into your Dummy node
Table.query("SELECT * FROM $1", export).cloneTo(Table(dump));

//Export the Dummy node information using the exporttable command
exporttable(dump, "TestExport.csv", 1, 0);

Hope this helps you some.

Export Test.fsm


export-test.fsm (66.8 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jeremy R avatar image Jeremy R commented ·

Thanks, this is a great help and exactly what I was looking for!


I also tried just using exporttable on the Performance Measures table directly and ran into the same problem. From your code and example model, it looks like the key trick is that querying the Performance Measures table converts the cells in the "Value" column from references to values. So all I need to do is query the Performance Measures table and save the query result to a treebound location (in order to export it), then I can just export that treebound table to get the results I was expecting.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.