question

Sebastien avatar image
0 Likes"
Sebastien asked Sebastien commented

Calculated table not updating

Hello !

I have a source giving random product type. In order to know how many product of what type I got in the sink, I used the entry trigger to update a global table. As I do not know how many different products I will have I added an insert column in the entry trigger of the sink in case the product has never been seen before.

But then my calculated table showing the results from the global table is not updating at all. It just keeps displaying the columns in the first state of the simulation, not the columns that were added during it. The "always" or "interval" updates do not work for this purpose.

Is there a way to update the calculated table with the column added in the global table during the simulation ?

I created a dummy example attached below:

EDIT:

I tried the solution from @Roi Sánchez but I do not know what i'm doing wrong. Could somebody help me ? I attached the updated model below.

Moreover how can we also update the dashboard linked with the calculated table to always take new columns into account ?

test-dynamic-calculated-table-v2.fsm

Best regards,

test-dynamic-calculated-tabble.fsm

FlexSim 19.0.0
sqlcalculated table
5 |100000

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

Roi Sánchez avatar image
3 Likes"
Roi Sánchez answered Sebastien commented

Hi @Sebastian, what I normally do is to set the update mode of the calculated table as "Manual" and then use the next code:

Object ct = Model.find("Tools/CalculatedTables/Output");
function_s(ct, "update", 1);

You can update the table each time an item gets processed.

· 2
5 |100000

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

Sebastien avatar image Sebastien commented ·

Hi @Roi Sánchez

Thank you for your help. I don't know what I am doing wrong but I can't get it to work. I created a new calculated table, put it on manual update and inserted your code in the exit trigger of the processor. I verified that I had the right object by printing the query in the output console but the update does not work.

Moreover I would have a second question related to this one. Is the same process working for updating the Dashboard linked with the Calculated table ?

Please find my updated model attached:

test-dynamic-calculated-table-v2.fsm

0 Likes 0 ·
Sebastien avatar image Sebastien commented ·

Hello @Roi Sánchez !

Thank you again for your answer and sorry I have not gotten back to you since.

I thought the application fo your solution was not working but actually it only works once. Is there a reason for that ? I tried looking for the meaning of the last parameter you added in the function_s. It should be a parameter for the update function but what does it mean in that case ? Changing it does not seem to do much.

0 Likes 0 ·
Roi Sánchez avatar image
0 Likes"
Roi Sánchez answered Sebastien commented

Hi @Sebastian, maybe the reason why your calculated table only gets updated once is because you have to use this code every time you want it to be updated. For example if your calculated table should change every time an item gets processed, you would have to use this code in the 'OnProcessFinish' trigger.

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

Sebastien avatar image Sebastien commented ·

I found the problem. I had your code in the Exit Trigger of my processor. If I put it at the end of my entry trigger in my sink then it works. Although I do not know why putting it it the exit trigger of the processor was problem as it should update it each time an item exits the processor.

Thank you for your help @Roi Sánchez

0 Likes 0 ·