Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
nikhilgarg
Specialist II
Specialist II

Error in script !!

Hey,

I want to sum the duration of time as per following script but it is showing me  00:00:00

=Sum({<Event= {'Server_DOWN'} , KeyStartTime= {">= $(=KeyDowntime_StartTime)"}, KeyEndTime= {"<= $(=KeyDowntime_EndTime)"}>} Duration)

What's wrong in this ??

5 Replies
Not applicable

Sum({<Event= {'Server_DOWN'} , KeyStartTime= {'>= $(=KeyDowntime_StartTime)'}, KeyEndTime= {'<= $(=KeyDowntime_EndTime)'}>} Duration)

try this expression ..

nikhilgarg
Specialist II
Specialist II
Author

Hey,

I tried this but it doesnot work out.

It still showing 00:00:00

arulsettu
Master III
Master III

hi

try like this

=Sum({<Event= {'Server_DOWN'} , KeyStartTime= {">= $(=KeyDowntime_StartTime) <=  $(=KeyDowntime_EndTime)"}>} Duration)

MK_QSL
MVP
MVP

CHECK ENCLOSED FILE

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

If KeyDowntime_StartTime and KeyDowntime_EndTime are fields, and you are attempting a row-by-row comparison, it won't work, because set analysis does not work like that. The set expression is evaluated once, not row by row.

You have two options -

  • Use a Sum(If(...)) expression. This will do the comparison row by row, but will perform poorly on large data sets

  • Create a flag field in your load script


     LOAD .....

          If(KeyStartTime >= KeyDowntime_StartTime And KeyStartTime <=  KeyDowntime_EndTime, 1, 0) As DTFlag,

          ....

     and use the flag in the set expression

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein