question

Maryam H2 avatar image
0 Likes"
Maryam H2 asked Ryan Clark commented

Find value in Global Table based on matching label

Hi,

If I created several labels based on patient type and want to look up the times based on each type from a global table. How could I find a matching global table value for a given label value ? In the Global Table I have the same labels for patient types I created at first.

In general how can I access the row header? It seems I cannot define a name for the first column where I have all my labels there.


1634047391598.png

Thanks!

FlexSim 21.2.3
global tablesrowheaderlabel matching to find row in the global table
1634047391598.png (14.6 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.

Ryan Clark avatar image Ryan Clark commented ·

Hi @Maryam H2, was one of Joerg Vogel's or @Felix Möhlmann's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. 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.

1 Like 1 ·

1 Answer

·
Joerg Vogel avatar image
2 Likes"
Joerg Vogel answered Maryam H2 commented

Table.getValueByKey(..) method

· 6
5 |100000

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

Joerg Vogel avatar image Joerg Vogel commented ·
If you need a string as reference of a header for a column or row, then you should try to use a custom code, because any template or activity has got restrictions to the overload of values.
Table(“myTableName”)[“rowHeaderName”][“columnHeaderName”]
0 Likes 0 ·
Maryam H2 avatar image Maryam H2 commented ·

Thanks @Joerg Vogel!

So, If I use custom code and want it to find the value in the global table by looking up the label on the item what should I put instead of rowHeaderName”? Does it mean the very first column where I have all reference labels there? The header is empty so how should I reference that?

After that, should I write this in custom code?

Table(“myTableName”)[“rowHeaderName”][“columnHeaderName”].getValueByKey(patient.Type)?or just Table(“myTableName”).getValueByKey(patient.Type)?

Also where in custom code, "Set Label"?


0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Maryam H2 commented ·

If you use Table("TableName")[row][col]" then "row" and "col" can either be the number of row/column or the header of the row/column.

Let's take the following table. I will type out some examples and what value they would return:

1634056339807.png

Table("GlobalTable1")[2][2]          -> 4   The second row/column are "BBB"/"Even"
Table("GlobalTable1")["BBB"]["Even"] -> 4
Table("GlobalTable1")["CCC"][1]      -> 5
Table("GlobalTable1")[1]["Odd"]      -> 1
Table("GlobalTable1")["EEE"]["Odd"]  -> 9

"getValueByKey" can not be used with the headers and works as follows

Table("GlobalTable1").getValueByKey(4, 1, 2)  -> 3

It returns the value from column 1 (second parameter), in the row where column 2 (third parameter) is equal to 4 (first parameter/key).

In your case, if you have the types as row headers, you'd use

Table("GlobalTable1")[patient.type][col]
2 Likes 2 ·
1634056339807.png (5.3 KiB)
Maryam H2 avatar image Maryam H2 Felix Möhlmann commented ·

Thanks @Felix Möhlmann

I have my labels in the first column where you have" AAA, BBB, CCC,..." and times in the second column. So where, should I define that chunk of code? custom code? where in custom code?

If I define it in the processing time, I'll get this error:

time: 453.528860 exception: FlexScript exception: Invalid row number: 0 in Global Table "SCH_Times" at MODEL:/Tools/ProcessFlow/Ortho Patients/MD Visit Process in Orthopedic>variables/delayTimeNode


0 Likes 0 ·
Show more comments

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.