Date calculation in analytics exspression

Hello,
I have to do a bar graph the depend on shift hours, for that I have to calculate a specific OEE value, in the formula I have to determine if current time is in 1st shift (06:00 - 15:00), 2nd shift (15:00-23:00) or 3rd shift (23:00-06:00) and calculate how many minutes are between current time and start of shift.
For example, if current time is 12:02, do 12:02 - 06:00 = 362 minutes, take this data and multiple with other fields.
I did :
round(sum((@Good_package_current - @Good_package_previous ) - (@Bad_package_current - @Good_package_previous )) / (8.5 * 60 * sum(date_trunc(@Start Time -‘06:00:00’)), 2)
But it’s not ok, got error on it, and it’s just a part of the expression (have to add the if …)

Please help me, how can I develop such expression ?

Regards,
Amit

I want just to clear something, I saw that the date_trunc doesn’t return a value of minutes, but I didn’t found any other function that does this conversion, so wrote the closest phrase, is there a function that returns minutes from begining of day from a desire hour ?

Amit

hello @ermingut, thanks for posting.

I would actually suggest solving this problem by adding a Variable in your App that is called Shift. upon starting or completing the App, you can store the Shift Name in that Variable depending on the If conditions on the @App Info.Current Date and Time. once you’ve done that, you can use that Variable to segment the Analysis as you’d like.

would this work as a solution for you?? let me know

I think that @Amit is trying to do all of this using MM only? I think that using an App here would also be a reasonable way to get more context on the data.

Hello all,
I have to do this function in the analytics only, not in the app, I have to make a bar graph of a calculated OEE value by a formula from my factory engineer.
For this formula I have the followin parameters :
A - Total Takts per minute (how many vakoom presses are in a minute)
B - Fix amount of takts per minute - constant of 8.5
C - Total minutes since begin of shift, for example, if the time now is 09:00 and the shift began at 06:00, so the number here will be 3 * 60 = 180
The formula is (A / (B * C)) * 100 that’s all, a very simple formula
The question in this discussion is how to calculate this time difference but in the analytics level, not in an application.

For the taks, I have a value of current non-initial field in the activity table that contain current number of takts since begin of machine history, so current record minus previous record for same field will return the value of current takt, this calculation I don’t know how to do either.

Please help me to resolve this issue.

Thank you,
Amit

Hi,
I am also looking into the similar kind of implementation regarding shifts.

I want to find which shift currently I am in and capture shift start time(along with date), end time (along with date) into variables and use them in KPI calculations and analysis. Do anyone have any solution for this?

Thanks,
Vamsi K

@Krish007 ,
I tried to do such expression for shift decision in an analytics and even tried to use support by office hours and we couldn’t get a solution for that, than I saw that the data that I have to use is subtrack of a value come from the machine between two records (current cycle count - previous cycle count), this calculation can’t be done in the analytics so I had to develop an app that do all those calculation into a tulip table, in this table I set the current shift number and used it in the analytics, the only disadventage by this solution is that the app must run on a player on a non-used computer or server 24/7, If you found any other solution, I will glad to know.

Kind regards,
Amit Berku

Hi @Amit, thanks for the info.

I am trying to solve this by storing my shift times (not dates included) as text format (example: shift A is from 07:00 to 13:00) in tulip table and in my trigger expression, building all the shift start and end times by comparing the current time with tulip tables time and finding which shift I am in, start date, end date and storing them in to variables and passing to analysis from filters.

This is working fine if I my shifts fall into a same day (00:00 to 08:00, 08:00 to 16:00, 16:00 to 24:00) but failing if my shifts fall into diff dates (07:00 to 15:00, 15:00 to 23:00, 23:00 to 07:00). Working on it and let you know if I found a way to figure it out.

Hi, you know that there is a shift managing in the Tulip, in the menu where you configure the users, I don’t know how to use it but maybe someone else can help us with that tool.

Kind regards,
Amit

| Krish007
November 17 |

  • | - |

Hi @Amit, thanks for the info.

I am trying to solve this by storing my shift times (not dates included) as text format (example: shift A is from 07:00 to 13:00) in tulip table and in my trigger expression, building all the shift start and end times by comparing the current time with tulip tables time and finding which shift I am in, start date, end date and storing them in to variables and passing to analysis from filters.

This is working fine if I my shifts fall into a same day (00:00 to 08:00, 08:00 to 16:00, 16:00 to 24:00) but failing if my shifts fall into diff dates (07:00 to 15:00, 15:00 to 23:00, 23:00 to 07:00). Working on it and let you know if I found a way to figure it out.

Yes I know but I can’t use it to capture shift start time and end time into my variables from that. That’s why I am working on this workaround.