question

tr-simulation avatar image
0 Likes"
tr-simulation asked tr-simulation commented

Help with exporting performance measure?

I would like to export the following data to excel (see screenshot). Can you walk me through it with screenshots? I tried to follow a thread from 2017 and 2021 but couldn't get it working. Thanks for the help.performance_measure_export.PNG

FlexSim 22.2.2
flexsim healthcare
· 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.

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @tr-simulation, was Jason Lightfoot's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·
Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot commented

Load this user library to imprint a command called exportPFM in your model.

Then use it like this:

exportPFM("NumScans");

ExportPFMcommand.fsl


· 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.

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·

ExportPFM() user command:

/**Custom Code*/
string pfmname=param(1);
string workbookname=param(2);
if (workbookname==""){
    workbookname=currentfile;
    workbookname=workbookname.slice(1,workbookname.length-3)+"_pfms.xlsx";
}
Database.Connection db = function_s(Model.find("Tools/Experimenter"), "getDBConnection");
 int disconnect = 0;
if (!db.isConnected) {
    if (!db.connect()) {
        return 0;
    }
    disconnect = 1;
}
 // Query for ID of best iteration
Database.ResultSet resultset= db.query("SELECT d.name AS Scenario, c.replication AS Replication, a.value AS "+pfmname+" FROM pfm_values a INNER JOIN pfms b, tasks c, scenarios d ON a.pfm_id=b.id AND c.id=a.task_id AND d.id=c.scenario_id WHERE b.name='"+pfmname+"' ORDER BY Scenario ASC, Replication ASC");
treenode tempnode=nodeinsertinto(Model.find("Tools").subnodes.assert("temp"));
 resultset.cloneTo(tempnode);
 Table temptable=Table(tempnode);
// Create new Excel workbook
excelcreateworkbook();
excelcreatesheet("PFMs");
excelsetsheet("PFMs");
excelexporttable(temptable,2,1,temptable.numRows,temptable.numCols);
for (int n=temptable.numCols;n>0;n--)
    excelwrite(temptable.getColHeader(n),1,n);
excelsave(workbookname);
excelclose(0);
tempnode.destroy();
if(disconnect) {    
    db.disconnect();
}



0 Likes 0 ·
tr-simulation avatar image
0 Likes"
tr-simulation answered tr-simulation commented

Another option I found was to go to experimenter > advanced tab > add a trigger using the green plus sign > select "at end of job" > export to CSV. For me this saved automatically to my downloads.

· 2
5 |100000

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

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·

For those finding this post and wondering what the difference is, the CSV standard output looks like this which is very useful as a report:

1676646267573.png

While the code in the answer above generates this which can be easier to process using queries.

1676646401015.png

0 Likes 0 ·
1676646267573.png (8.3 KiB)
1676646401015.png (4.4 KiB)
tr-simulation avatar image tr-simulation Jason Lightfoot ♦ commented ·
Thank you!!
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.