question

Ankur A3 avatar image
0 Likes"
Ankur A3 asked Kavika F commented

How to use 2 row headers without clearing 1st row while reset?

Hi Team,

I have 2 row headers in string format in global table as below in image. I want to write data from 2nd row in this table using code. While using clear all cells options of global table at reset my 1st row data is also getting clear. How retain data for 1st row as these are headers of table format?

1651825303225.png

Thank you!

FlexSim 20.0.10
global tableclear all
1651825303225.png (5.5 KiB)
· 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.

Kavika F avatar image Kavika F ♦ commented ·

Hi @Ankur A3, was one of Felix Möhlmann's or Jason Lightfoot's or Joerg Vogel's or Iago MF'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 ·
Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Felix Möhlmann edited

The 'Delete All Rows' option uses the 'Table.setSize()' command. You can edit the number of rows in the code window and set it to 1, so the trigger will leave the first row.

1651832427244.png


1651832427244.png (13.7 KiB)
· 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.

Ankur A3 avatar image Ankur A3 commented ·

Hi @Felix Möhlmann,

I agree to you your point but I want to use clear cells also along with delete all option. but that is erasing the entry for 1st row which should not be the case since I am using it as header?

I tried changing row loop but even that is not solving my purpose.

1652090089503.png

My intention is to clearing cells from 2nd row. Can you suggest what I need to change if I am doing something wrong here?

Thank you!

0 Likes 0 ·
1652090089503.png (51.3 KiB)
Felix Möhlmann avatar image Felix Möhlmann Ankur A3 commented ·

The table is cleared in line 10 ("current.clear()"). That command sets all cells to an appropriate 'empty' value based on the datatype. The code afterwards checks for certain types that are not covered by the command.

I don't understand your intention though. Why would you need to clear cells which you just deleted?

0 Likes 0 ·
Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot commented

Have you considered

  • renaming your column headers Mon-A, Mon-B, Mon-C, Tue-A etc.
  • having column headers, Name, Day, Shift and then a row for each of your shift assignments

That way you can preserve the table integrity and use SQL or other functions without having to allow for row 1 being a header.

By the way you can preserve the column headers and have no rows using :

  1. Table("GlobalTable1").setSize(0,Table("GlobalTable1").numCols)
· 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.

Ankur A3 avatar image Ankur A3 commented ·
Hi @Jason Lightfoot,

I don't understand properly. I only understood 1st point to consider Weedays Name based on column like Mon-A, Mon-B............etc. Can you upload screenshot or model for better explanation?

Thank you!

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Ankur A3 commented ·

Here's an example:

1652091627602.png

From this data you can either retrieve it globally using select statements like

SELECT Shift FROM ShiftAllocation WHERE Person='Pete' AND Day='Mon'

..or you can use it to make a data structure on the object as a label. In your version that would be a table or array or in the later versions you could create a Map type where reading the value is really simple:

Map shiftmap=operator.shiftMap;  // the label
string shift =shiftMap["Mon"];   //sets the shift local variable to 'A'  for example.


0 Likes 0 ·
1652091627602.png (7.7 KiB)
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Joerg Vogel commented

FlexSim has got only one header row! First table row is a data row!

You can only fill first row with values upon reset in a trigger yourself, but please keep in mind, you maybe mix different datatypes in columns!

· 4
5 |100000

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

Ankur A3 avatar image Ankur A3 commented ·

Hi @Joerg Vogel ,

I got your point. But how to access cell with column name here if we don't have any column name in top header (case 1) or we have same column name in top header (case 2). Do you have any idea?

case1:

Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8

Mon Tue

Case 2:

Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8

Mon Mon Mon Mon Tue Tue Tue Tue

Is there any way to do it more effectively?

Thank you!

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Ankur A3 commented ·
I'm not sure if I entirely understand you goal, but generally you could jstu combine the two expressions into one and create unique headers that way.

Mon_A Mon_B Mon_C Tue_A Tue_B Tue_C

When you know both parts you can combine them with a '+'.

string day = "Mon";
string ID = "B";
int value = Table(tableName)[row][day + "_" + ID];
0 Likes 0 ·
Ankur A3 avatar image Ankur A3 commented ·

Hi @Joerg Vogel ,

I got your point. But how to access cell with column name here if we don't have any column name in top header (case 1) or we have same column name in top header (case 2). Do you have any idea?

case1:

Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8

Mon Tue

Case 2:

Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8

Mon Mon Mon Mon Tue Tue Tue Tue


Is there any way to do it more effectively?

Thank you!

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Ankur A3 commented ·

If you have want to get access to a multiheader table structure, you can convert a table cell address to an array and put each cell into a List to look for field values matching your conditions like

List("List1").pull("WHERE name = 'a' AND weekday = 'tue',0,0);

translate_table_to_list_multiple_keys.fsm

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.