Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
hopkinsc
Partner - Specialist III
Partner - Specialist III

Help with script

Hi All

I am trying to work out how long a call is open for. The working day is between 9 -5 Mon-Fri. If a call is opened on a saturday then qlikview should report it as being opened on the Monday. and if the call is closed on the weekend then qlikview should report it as being closed on friday end of day. If any calls are open and closed on weekday then qlikview should report the actual day.

This is what i have used for my start/end times..

timestamp(LastWorkDate([Create DateTime],1,$(vBankHols))+$(vWeekDayStartTime)) as [Create WorkingDateTime],  // roll forward to Monday SoD (*1)

timestamp(FirstWorkDate([Closed DateTime],1,$(vBankHols))+$(vWeekDayEndTime)) as [Closed WorkingDateTime],  // roll backward to Friday EoD (*1)

The problem i am getting is that my new field [Create WorkingDateTime] displays ALL original call open times as 9am. I only want it to be 9am (The following Monday) if opened on a weekend.

Does anyone have any ideas?

4 Replies
hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

hi all, anyone have any ideas?

Not applicable

Hi hopkins,

the LastWorkDate(Date, 1) returns in case of Workdays the Day itself, otherwise the next Workday. In both cases your are adding the timeoffset  "$(vWeekDayStartTime)".

So try this modification of your expression:

Timestamp(LastWorkDate([Create DateTime],1) + if(weekDay([Create DateTime])>4, $(vWeekDayStartTime),0)

HtH

Roland

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Hi, thanks for that, it seems to work if you select a weekend but if you select a week day or no day at all (So all days are selected) it returns 00:00:00 as the time..

The time needs ti stay as the original time logged if logged on Mon-Fri 9-5.

Thanks

Chris

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Any more help with this anyone?