question

kauan pedroso avatar image
0 Likes"
kauan pedroso asked Felix Möhlmann commented

create a column indicating the shift

I have a global table that takes some data from sql server that brings me all the data but I would like to make a graph where I can see the performance of the morning, afternoon and night shifts. Is it possible in the charts to create a filter by date?


FlexSim 21.2.4
global tablesql servershift
· 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.

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Felix Möhlmann commented

That is pretty much what I tried to describe in my comment. The code to determine would look something like this (missing the reference to the table that you would have to provide).

  1. Table current = Table("GlobalTable1");
  2. for(int row = 1; row <= current.numRows; row++)
  3. {
  4.     DateTime entryTime = DateTime(current[row]["InputTimestamp"]);
  5.     if(entryTime.hour >= 5 && entryTime.hour < 12)
  6.     {
  7.         current[row][3] = 1;
  8.         continue;
  9.     }
  10.     if(entryTime.hour >= 12 && entryTime.hour < 22)
  11.     {
  12.         current[row][3] = 2;
  13.         continue;
  14.     }
  15.     current[row][3] = 3;
  16. }

This code loops through the entire table. If you add the entries one by one you can of course directly compute the shift for just that row.

To then get the average into a bar chart you can use a calculated table to get the average value of the Difference column partitioned by the shift.

Either use the options on the first and third tab to generate the query or enable the direct editing to type it in manually.

1682404458679.png


1682404458679.png (21.4 KiB)
· 8
5 |100000

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