question

Luis Fernando avatar image
0 Likes"
Luis Fernando asked Jeanette F commented

How to set a conditional decide if a label is = to a value in a global table

Hi FlexSim team,


I would like to set a conditional decide in the case that the label value match with the value of a global table depending on the "model" label.

I place this in the conditional decide:
token.Pieza.TimesProcessed == Table("GlobalTable3").getValueByKey(token.Model,"TimesProcessed",1)

Could you tell me where is the mistake?

1669933699207.png


Thank you,

Luis


1.1 Conditional decide by (depending) model label.fsm

FlexSim 22.2.3
conditional decidematch labelgetvaluebykey
· 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 @Luis Fernando, was one of Luis Fernando's or Jordan Johnson'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.

0 Likes 0 ·

1 Answer

Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered Luis Fernando commented

Table.getValueByKey() is meant to find a value in a column, not a row header. In your case, you can just use:

token.Pieza.TimesProcessed == Table("GlobalTable3")["F"][1]
· 5
5 |100000

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

Luis Fernando avatar image Luis Fernando commented ·

Hi Jordan,

Actually I would like to find a value in a column. I mean, for example if the "TimesProcessed" label value is = 1 just on exit processor and in the specifications (Global Table) shows that must be processed 2 times, then returns a false value (1 ≠ 2) and then go back again to the process.

I think this is not what I am looking for:

  1. token.Pieza.TimesProcessed == Table("GlobalTable3")["F"][1]


Thank you!

Luis

0 Likes 0 ·
Luis Fernando avatar image Luis Fernando commented ·

In the other hand I have different models with different specifications:
1669937269072.png


How could I find from the global table and if it match with the label then returns a TRUE value.

0 Likes 0 ·
1669937269072.png (5.6 KiB)
Joerg Vogel avatar image Joerg Vogel Luis Fernando commented ·

Any value different casted into an integer 0 is interpreted as true.

1, 2, 7, 2037 and so on is true if a function returns it as a result. If you try to find in a condition the a value of a matching key value and you get as possible return values a number different to 0 than this value is a true.

In your case you try to find a value of token.Model in Column TimesProcessed to retrieve all matching Values of Column TimesProcessed. This means if you try to find Token.Model value is 2 you get an array [2,2,2,2,2]. Now you want to compare it equally to token.Pieza.TimesProcessed. It would be easier to compare

token.Pieza.TimesProcessed == token.Model. If you want to get a different answer, can you tell us more about the values of label token.Pieza.TimesProcessed ? Thanks!




0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Luis Fernando commented ·

I think Jordan was just trying to express that you can use the row header to access the correct row directly and used "F" as an example. In general, the row header is given by your "Model" label, so the expression you are looking for is

token.Pieza.TimesProcessed == Table("GlobalTable3")[token.Model][1]
0 Likes 0 ·
Luis Fernando avatar image Luis Fernando Felix Möhlmann commented ·

Thank you so much Jordan, Joerg and Felix.
This works as I was looking for:

  1. token.Pieza.TimesProcessed == Table("GlobalTable3")[token.Model][1]


Have a great day,
Luis

0 Likes 0 ·