question

Sinisa avatar image
1 Like"
Sinisa asked Mischa Spelt commented

Calculate in the Global Table?

Hey guys :)

I have a problem , i want to, for example multiply in a new row the variable(Laenge*Breite*Hoehe) like in excel , is this possible ? (Can i add formulas)

Thanks

FlexSim 17.1.2
global tableformulacalculating
calculate.png (6.0 KiB)
5 |100000

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

Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered Matt Long commented

You can put a formula in a cell, but it won't display the calculated value - you'll only be able to evaluate the formula and get the calculated value when you ask for it.

If you set the datatype of the column to FlexScript you can then enter a formula in FlexScript:

Table table = Table("GlobalTable1");
return table[1][1] * 10; 

Then you can get the value out like this:

Table("GlobalTable1")[1][2]

That will execute the code in that cell and return the calculated value.

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

Matt Long avatar image Matt Long commented ·

Or in one line:

Table("GlobalTable1")[1][1] * 10

1 Like 1 ·
executecell.png (7.7 KiB)
Matt Long avatar image
1 Like"
Matt Long answered Mischa Spelt commented

Unfortunately FlexSim does not support formulas in tables. You would have to write code somewhere outside of the table to update the table's cells. Or if you only need it on reset, you could use the Global Table's On Reset trigger.

If you'd like to see this feature added to FlexSim you could repost this as an Idea in the Development space. This allows users to vote on the idea and tells the developers which ideas are popular for future releases.

· 3
5 |100000

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

Sinisa avatar image Sinisa commented ·

Thanks for your help :) can you explain me the Global Table's On Reset trigger a little bit better please ?

I will look forward to do that !

0 Likes 0 ·
Matt Long avatar image Matt Long Sinisa commented ·

When you hit the Reset button and reset your model, the Global Table will fire its On Reset trigger. There are a few pick options available for clearing data in the table or you can write your own custom code. If you open the code you'll see that current references the table, so you can write code like:

Table current = param(1); //Table node
current[1][3] = current[1][1] * current[1][2];
1 Like 1 ·
Mischa Spelt avatar image Mischa Spelt Matt Long commented ·

And if you want to do this for all rows, add a loop:

Table current = param(1); 
for(int row = 1; row <= current.numRows; i++) {
  // Multiply columns 1 and 2 and store the result in column 3
  current[row][3] = current[row][1] * current[row][2];
}
1 Like 1 ·

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.