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

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need help with some logic problem

i have table like this one:

1.bmp

what i am tring to do is:

finding for each start time its end time, but taking only end time with BIT = 0.

for exemple:

for line no.1 : its easy i can take the line as is .

for line no. 2: i see that the BIT is 1 so i keep looking for 0 i get it at 5/1/2011 1:00 AM, so here i have START_TIME 2/1/2011 1:00 AM and END_TIME 5/1/2011 1:00 AM and the BIT will be 0.

for the last one: START_TIME 6/1/2011 12:00 PM and END_TIME 9/1/2011 12:00 AM but keep the BIT with the value 1.

does someone know hoe to do this?

thank you .

1 Reply
Not applicable
Author

Hi,

Try this:

load

     ID,

     Start_time,

     if(Bit=0,End_time,if(previous(Bit)=0,previous(End_time),

          if(previous(previous(Bit))=0, previous(previous(End_time)) enz..     as End_time

resident Table

order by Start_time DESC;

I hope it is de start of your solution.

Halmar