question

Scarlett X avatar image
1 Like"
Scarlett X asked Felix Möhlmann commented

lookup by value

I have the type on item, and I hope it set a newlable correspond to item.type, ex: type=2 then it lookup the value 2 is in row1 , so it set the newlable value is 8.

Now , if type=2, my model will lookup row2 to set newlable is 7 , but that's not what I want.

Can I do that? Thank you.

2022-11-11-15-35-30-window.png

FlexSim 22.1.0
global tables
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

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Felix Möhlmann commented

The command "Table().getRowByKey(key, column)" will return the row number of the first row in which the value of "column" is equal to "key". You can use this to find the correct row based on the label value.

Alternatively, you could duplicate the "type" column and use those values as the row headers. You can then directly refer to the correct row by converting the label value to a string (row headers are always text).

1668157766871.png

The screenshot shows the On Entry trigger of a queue. But you can of course use this elsewhere as well.


1668157766871.png (21.2 KiB)
· 4
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 ·

Some notes on these methods' speed with large tables (eg.10000 rows)

  • Slowest (x1) is getRowBykey with node based tables
  • Next fastest (x4) getRowByKey with bundled data or rowheaders with node tables.
  • Fastest (x1000) getRowByKey with bundle data and field index.

So if you're using getRowByKey and can use bundle data it's worth flipping the switch to that type for an x4 speed boost, and if possible add an index for x1000.

2 Likes 2 ·
Scarlett X avatar image Scarlett X commented ·
Thank you all!!
0 Likes 0 ·
Scarlett X avatar image Scarlett X commented ·
Could I use getRowByKey in token?
0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Scarlett X commented ·
You can use the command anywhere in the model, including Process Flow and pass in the key via a token label, for example.
Table(GlobalTable1).getRowByKey(token.Type, 1)
0 Likes 0 ·