Check for a specific condition in row/s above

Hi. I need some help with my problem here. Im trying to figure out how to check the row before and after (within 24hours) if a certain row with a condition exists.

Below is my sample data. Here, I have row number 2 which has ALARM>0 then I want to check if CB_OPEN before that and followed by CB_CLOSE after the Last NORMAL. This should happen within the same bay_name only. The event CB_OPEN > ALARM > NORMAL > CB_CLOSE.

Row_ID bay_name tag time Count_ALARM Count_NORMAL CB_Position
1 RNGT.E04.BSEC1 RNGT.E04.BSEC1.Pos 2023-04-26 22:32:46 CB_OPEN
2 RNGT.E04.BSEC1 RNGT.E04.BSEC1.SF6Stg1 2023-04-26 22:38:57 20
3 RNGT.E04.BSEC1 RNGT.E04.BSEC1.SF6Stg1 2023-04-26 22:55:57 20
4 RNGT.E04.BSEC1 RNGT.E04.BSEC1.Pos 2023-04-26 23:01:49 CB_CLOSE
5 RNGT.E05.BPHE RNGT.E05.BPHE.Pos 2023-04-26 23:03:53 CB_OPEN
6 RNGT.E05.BPHE RNGT.E05.BPHE.SF6Stg1 2023-04-26 23:08:56 55
7 RNGT.E05.BPHE RNGT.E05.BPHE.SF6Stg1 2023-04-26 23:33:57 55
8 RNGT.E05.BPHE RNGT.E05.BPHE.Pos 2023-04-26 23:36:15 CB_CLOSE
9 RNGT.E03.TLBH RNGT.E03.TLBH.Pos 2023-04-26 23:37:13 CB_OPEN
10 RNGT.E03.TLBH RNGT.E03.TLBH.SF6Stg1 2023-04-26 23:42:34 32
11 RNGT.E03.TLBH RNGT.E03.TLBH.SF6Stg1 2023-04-26 23:59:34 32
12 RNGT.E03.TLBH RNGT.E03.TLBH.Pos 2023-04-27 00:03:10 CB_CLOSE

I have a long list of data. I want to find events such as CB_OPEN > ALARM > NORMAL > CB_CLOSE. Not all cases will have CB_OPEN or CB_CLOSE. So My idea is to check for ALARM>0 and look for CB_OPEN within 24 hours before the ALARM occurred and CB_CLOSE within 24 hours after NORMAL>0.

Any help on this is highly appreciated. :slight_smile:

Hi,
Welcome to the KNIME Forum! I would use a Group Loop Start to loop through the data in batches, where every batch contains one bay. So the group column for the node is your bay ID. Then in the loop, you can use Lag Column nodes to bring the CB_Position and the time from the previous rows to the current one. If you want to check the 3 previous rows, set lag to 3 and interval to 1. Now you can use a Rule Engine to check your conditions. End the loop with a Loop End to collect the data from all iterations.
Kind regards
Alexander

2 Likes

hi @saravanans

Or do something like this
Schermafdruk van 2023-04-29 12-05-46
After pivoting you can apply a RuleEngine to check for specific conditions.

gr. Hans

1 Like

Hi HansS. Spot on. I have used this method without realizingly and it worked. Thank you very much.

1 Like

Alex, Im exploring loop function and trying to make it work since I need it for next step of my problem. At the moment @HansS solution is working fine.Thank you Alex.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.