# Calculate the difference between numbers based on the other column values

Hi everyone,
I have a dataset and I am trying to calculate the time duration of a production stoppage. When the values are equal to 0, it means that the production was stopped. In order to find the time duration of multiple production stoppages, I need to calculate the difference: time of the last occurring 0 - time of the first occurring 0. As it can be seen from this dataset, there are 2 production stoppages, one starts at 3rd min and other one starts at the 10th min.

Time(min) Production
1 0.3
2 0.27
3 0
4 0
5 0
6 0
7 0.8
8 0.1
9 0.45
10 0
11 0

Could you guide me how I can make it in KNIME?

hi @curioushuman and Welcome to the KNIME world,

so, youâ€™re interested in the duration between these stoppages (7). Please have a look at the following Workflowâ€¦

I first get rid of the 0 -> 0 sequences and then filter on the Production = 0. Afterwards a lag column gives you the Time of the last â€ś0â€ť and then a simple subtraction (Math Formula) calculates the time difference.

Hope, that helps, Greetz,
Tommy

5 Likes

Thank you so much Tommy! It worked like a charm

1 Like

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