I have a dataset where I want to "flag" every time a call is forwarded. It can be forwarded back and forth between the same departments, but have to count every time it occurs. A call can also be forwarded within the same department but then it shall not be flaged. When a call is received it gets an id that is "locked" until the call has ended. I have tried to give the example below. The first four columns is what I already have. id datetime department count flag 1 01-01-2020 10:00 aaa 1 1 1 02-01-2020 10:00 bbb 2 1 1 03-01-2020 10:00 ccc 3 1 1 04-01-2020 10:00 aaa 4 0 1 05-01-2020 10:00 aaa 5 1 1 06-01-2020 10:00 ccc 6 0 2 01-01-2020 10:00 bbb 1 0 2 02-01-2020 10:00 bbb 2 0 2 03-01-2020 10:00 bbb 3 0 2 04-01-2020 10:00 bbb 4 0 2 05-01-2020 10:00 bbb 5 0 3 01-01-2020 10:00 aaa 1 1 3 02-01-2020 10:00 ddd 2 0 3 03-01-2020 10:00 ddd 3 0 3 04-01-2020 10:00 ddd 4 1 3 05-01-2020 10:00 aaa 5 0
... View more