lookup by value

lookup by value

sherry_x
Not applicable
1,237 Views
5 Replies
Message 1 of 6

lookup by value

sherry_x
Not applicable

[ FlexSim 22.1.0 ]

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

Accepted solutions (1)
1,238 Views
5 Replies
Replies (5)
Message 2 of 6

FelixMoehlmann
Collaborator
Collaborator
Accepted solution

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.

0 Likes
Message 3 of 6

jason_lightfoot_adsk
Autodesk
Autodesk

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.

Message 4 of 6

sherry_x
Not applicable
Thank you all!!
0 Likes
Message 5 of 6

sherry_x
Not applicable
Could I use getRowByKey in token?
0 Likes
Message 6 of 6

FelixMoehlmann
Collaborator
Collaborator
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