create a column indicating the shift

Kauan
Not applicable
3 Views
11 Replies
Message 1 of 12

create a column indicating the shift

Kauan
Not applicable

[ FlexSim 21.2.4 ]

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?


0 Likes
Accepted solutions (1)
4 Views
11 Replies
Replies (11)
Message 2 of 12

moehlmann_fe
Community Visitor
Community Visitor

What data exactly do you want to plot in a chart: The data from your global table, the state/utilization of objects, a throughput value, ...?

In general, if you have time stamps, you can use the datetime class to create a column that denotes the shift the data point belongs to by using simple conditions like "DateTime(...).hour >= 8 && DateTime(...).hour < 16".

Once you have such a column you can partition the data by it, either in a calculated table if you need to filter/aggregate the other data first, or directly through the properties of certain chart types.

0 Likes
Message 3 of 12

Kauan
Not applicable

Hello @Felix Möhlmann

I think I didn't explain well what I want, I'm looking to make a bar chart where I can show the average cycle time per shift. I had an idea but I don't know if it's the best option, which is to create an extra column in my global table and identify which shift my cycle time is in. example if it is between 05:00 to 12:00 = T1 if it is from 12:01 to 22:00 = T2 and until 22:01 to 05:00 = T3. Is it possible to do that? Is it the most viable option ?

1682367432462.png

Image.png



0 Likes
Message 4 of 12

moehlmann_fe
Community Visitor
Community Visitor
Accepted solution

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

Table current = Table("GlobalTable1");
for(int row = 1; row <= current.numRows; row++)
{
    DateTime entryTime = DateTime(current[row]["InputTimestamp"]);
    if(entryTime.hour >= 5 && entryTime.hour < 12)
    {
        current[row][3] = 1;
        continue;
    }
    if(entryTime.hour >= 12 && entryTime.hour < 22)
    {
        current[row][3] = 2;
        continue;
    }
    current[row][3] = 3;
}

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

0 Likes
Message 5 of 12

Kauan
Not applicable

in the code above it changes the value of my inputTimestap, how do I change the shift column. Another thing I will share the model, would you show me this calculated field better?

1682420768440.png

1682420787659.png

busca-de-dados-3-autosave-jl3_autosave.fsm

0 Likes
Message 6 of 12

jason_lightfootVL7B4
Autodesk
Autodesk

You can use this to set your shift number if shifts 1,2 and 3 correspond to 0-8hrs, 8-16hrs, 16-24hrs:

Table.query("UPDATE GlobalTable1 SET Shift = 1+(DateTime(InputTimestamp).hour>=8)+(DateTime(InputTimestamp).hour>=16)");
0 Likes
Message 7 of 12

moehlmann_fe
Community Visitor
Community Visitor

In my example model the Shift column was the third one in the table. You have the change the column number/name when assigning the shift values to reflect your table format.

0 Likes
Message 8 of 12

Kauan
Not applicable

Hello @Jason Lightfoot

Thank you very much.


0 Likes
Message 9 of 12

Kauan
Not applicable

Hello @Felix Möhlmann


Thank you very much.

0 Likes
Message 10 of 12

Kauan
Not applicable

One last doubt, I realized that both methods work and if I wanted to get a time with minutes. Example 12:30 what do i need to change to do this.

0 Likes
Message 11 of 12

Kauan
Not applicable

One last doubt, I realized that both methods work and if I wanted to get a time with minutes. Example 12:30 what do i need to change to do this.

0 Likes
Message 12 of 12

moehlmann_fe
Community Visitor
Community Visitor

You could add the minutes to the different conditions (DateTime.minute). But I would suggest to calculate the current time of day as a decimal hour value and compare the shift times to that.

As an example

DateTime entryTime = DateTime(current[row]["InputTimestamp"]): double timeOfDay = entryTime.hour + entryTime.minute/60; if(entryTime.hour >= 5 && entryTime.hour < 12.5) {           current[row]["Shift"] = 1;           continue; } ...


0 Likes