Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

datanibbler
Not applicable

Reworking a code

Hi,

I have a piece of code that does roughly the following:

- Target values per day, shift (there are 2) and dpt. are loaded from a file;

- Minute_intervals are created from 05:20 (beginning of a working day) till 22:30 (end of a working day)

- They are joined.

The important point for now is: The code now generates time_intervals which we move towards - so the intervals are always in the future, so to speak. It looks like this:

LOAD

    ...

if(Interval_Min<730,'07:30', if(Interval_Min<1000,'10:00', if(Interval_Min<1200,'12:00', if(Interval_Min<1400,'14:00',
if(Interval_Min<1600,'16:00', if(Interval_Min<1830,'18:30', if(Interval_Min<2030,'20:30', if(Interval_Min<2230,'22:30','22:30')))))))) as Interval_2H,

...

;

The field Interval_Min has every minute of the day between the start- and end-times. These are not real timestamps of course, by now I have those, but that is not the point - this kind of nested IF-constructs is not quite my idea of efficiency. So would there be any other, slimmer way of doing this?

Thanks a lot!

Best regards,

DataNibbler

2 Replies
marcus_malinow
Not applicable

Re: Reworking a code

IntervalMatch would be a little simpler

datanibbler
Not applicable

Re: Reworking a code

Hi,

now I have another issue:

A new piece of code that I have introduced in this script now autogenerates "real" minutes (60 to an hour) between 5:20 am and 10:30 pm.

<=> For one field (>interval_hr<) in the code following this, I need to split out the hours:

- One "2hr-interval" during the day is 10am, the next is 12am

=> The minute-intervals I have inbetween there are all from 10:01 to 11:59

=> The hr-intervals should be 11 and 12

How to split out the hour-part now from the minute-intervals (if I could do this, then just adding 1 would be enough)

Here is the code that generates these intervals:

SET vShiftStart=Time#('5:20:00');
Set vShiftEnd=Time#('22:30:00');

Time($(vShiftStart) + Time#('00:01:00')*(IterNo()-1), 'hh:mm') as Interval_Min
AutoGenerate (1)
While Time($(vShiftStart) + Time#('00:01:00')*(IterNo()-1), 'hh:mm') <= $(vShiftEnd);
;

I tried the Hour() function, but then I'd end up with the "hour-intervals" 11, 12 and 13.

Can anyone help me here?

Thanks a lot!

Best regards,

DataNibbler