Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I want to calculate if a time I obtain from the production of certain objects is before or after 15:45:00 of each day I am taking into consideration.
So, my idea was to do like this:
Time(Min({<ACTION_CODE={'LABOR_ON'}>} DateTime)) - MakeTime(15,45,00)
But when I compare these two, it gives me a very big number, and it seems like the time I create with MakeTime is associated with a very early date instead of just being the time only. How can I deal with this? I just want to understand if an event has happened before this datetime.
@alespooletto Sorry and Exactly, With Binary conditions combination you can be able to because like I said that data shows with Time and not full timestamp so Qlik not able to process the Time if that is with Date.
@Anil_Babu_Samineni Hey, sorry for the delay. I was able to work with this in a different, and actually easier way. But so far, I only have to work on adding a couple more details, such as removing 16 hours when the product was started at 17:29 for example and finished 8:31 the next day. Or 48+16 hours if it's started on Friday and finished Monday.
This is the current formula. I feel like adding new IFs at the end would be the straightforward choice. But I am curious if in QLIK there is a function like SWITCH in Power BI, where you can get multiple IF statements at once?
Interval(
Max({<ACTION_CODE={'LABOR_OFF'}>} DateTime) -
Min({<ACTION_CODE={'LABOR_ON'}>} DateTime) -
If(
// Break period 10:00 to 10:15
(
(Hour(Min({<ACTION_CODE={'LABOR_ON'}>} DateTime)) <= 10 AND Minute(Min({<ACTION_CODE={'LABOR_ON'}>} DateTime)) < 0) AND
(Hour(Max({<ACTION_CODE={'LABOR_OFF'}>} DateTime)) >= 10 AND Minute(Min({<ACTION_CODE={'LABOR_ON'}>} DateTime)) > 15)
) OR
// Break period 15:45 to 16:00
(
(Hour(Min({<ACTION_CODE={'LABOR_ON'}>} DateTime)) <= 15 AND Minute(Min({<ACTION_CODE={'LABOR_ON'}>} DateTime)) < 45) AND
(Hour(Max({<ACTION_CODE={'LABOR_OFF'}>} DateTime)) >= 16 AND Minute(Min({<ACTION_CODE={'LABOR_ON'}>} DateTime)) > 0)
),
// Subtract 15 minutes
Interval(0.0104167),
// ELSE IF Break period 12:30 - 13:30
If(
(
(Hour(Min({<ACTION_CODE={'LABOR_ON'}>} DateTime)) <= 12 AND Minute(Min({<ACTION_CODE={'LABOR_ON'}>} DateTime)) < 30) AND
(Hour(Max({<ACTION_CODE={'LABOR_OFF'}>} DateTime)) >= 13 AND Minute(Max({<ACTION_CODE={'LABOR_OFF'}>} DateTime)) >= 30)
),
// Subtract 1 hour
Interval(0.0416667),
// ELSE
0 // No adjustment
)
),
'hh:mm:ss'
)
@alespooletto SWITCH is there, but not in UX and it is designed only in Script So, I would recommend you move from UX to script level because such conditions will degrade the performance on object level, and it decreases the performance of whole dashboard.
Yes, I think it's better to move all at the script level. The only issue I have is when I tried before, I couldn't seem to use operations such as
Hour(Max({<ACTION_CODE={'LABOR_OFF'}>} DateTime))
Because it wouldn't properly read those {} graphs
Thank you so much again.