I have the following daily production data for each machine and I need to identify all the dates where the machine did not work for a minimum of 3 days. I should count dates only after the machine worked for at least 3 consecutive days. For example, Jan 2-4 below should not be counted because the machine did not work for 3 consecutive days yet until those dates.
Machine | Date | Production |
A | 1/1/2021 | 1 |
A | 1/2/2021 | 0 |
A | 1/3/2021 | 0 |
A | 1/4/2021 | 0 |
A | 1/5/2021 | 1 |
A | 1/6/2021 | 1 |
A | 1/7/2021 | 1 |
A | 1/8/2021 | 0 |
A | 1/9/2021 | 0 |
A | 1/10/2021 | 0 |
A | 1/11/2021 | 7 |
A | 1/12/2021 | 0 |
A | 1/13/2021 | 0 |
A | 1/14/2021 | 0 |
A | 1/15/2021 | 0 |
A | 1/16/2021 | 2 |
A | 1/17/2021 | 3 |
A | 1/18/2021 | 4 |
A | 1/19/2021 | 0 |
A | 1/20/2021 | 0 |
The output should look like the table below:
Machine | Start Date | Number of Days |
A | 1/8/2021 | 3 |
A | 1/12/2021 | 4 |
B | …. | …. |
Highly appreciate your help!
Solved! Go to Solution.
@Qiu, The machine should work for at least 3 consecutive days (>0 production) before we identify consecutive zeros. Therefore, we should start identifying consecutive min 3 days zeroes after Jan 7 for Machine A because it worked for 3 consecutive days first time on Jan 5-7.
Thanks a lot for your help!
But before 1/12/2021 does not have 3 consecutive days work also.
@SerhatB
Anyway, if I consider 1/12/2021 is a mistake.
3 consecutive production days not necessarily need to be immediately before the 3 consecutive zero production days. It can be at anytime in the dataset. In this case, there is a consecutive 3 days production at Jan 5-7 and we can start counting consecutive zero productions after Jan 7. Thank you!
Thank you very much Qiu, this is super helpful! 🙏
@SerhatB
Glad to help and thank you for the accept mark
User | Count |
---|---|
19 | |
14 | |
13 | |
9 | |
8 |