question

Jouky D avatar image
0 Likes"
Jouky D asked Jouky D commented

How to put an array of values into a row or column of a table?

Hello everyone,

I need to put an array of values into a row and other into a column of a table. One way to do it is using a for loop entering value per value, however I don't know if this is the optimal way. Maybe there is a command for that as:
table[Row2][*] = MyArray;

table[*][Col3] = MyArray;

Is there an optimal option than a for loop?

FlexSim 23.2.1
sqltablesarray
· 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.

Jouky D avatar image Jouky D commented ·
In addition, the array has lots of zeros.
0 Likes 0 ·
Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

Assuming you want one value per table cell there is currently no predefined method for this - a loop is your best bet, but you can write a user command to do this quite easily and then reuse it (passing the array as a variant and the table and range you want to apply it to).

You could also suggest an idea on this site that adding or updating a row based on a set of array values would be useful - I'm less sure about the column application and how that might work with, for example, sql.

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

Jouky D avatar image Jouky D commented ·
I did it using a for loop. This can be useful with sparse matrix to only take the row, column and value only, and not the zeros. Thank you.
0 Likes 0 ·
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Jouky D commented

array-in-table-cell.jpg

you can change table cell datatype:

aggregate table row or column to array

aggregate-table-col-row-to-array.jpg

Aggregate_table_col_row_to_array.fsm



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

Jouky D avatar image Jouky D commented ·
Thank you for your answer. However, I needed to join the array into the table. Using a for loop is find (I didn't know if there is other optimal commands for that). Thank you!
0 Likes 0 ·

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.