Hi everyone. First post here, so please let me know if anything is not according to the guidelines.
This is a snippet from a table in which data is collected from the brewery I work at (not all columns are depicted):
It has columns for batch number, tank number, brew date and tank emptying date. Now, I need to extract the number of days, by month, that a tank is unused, i.e. empty. For example, tank 5 was emptied on the 6th of september, but subsequently filled on the 14th, so it was empty for the 7 days in between. To make things even more complicated (at least to me): if a tank was emptied on a Friday, but filled on a Monday, the weekend shouldn't be considered as unused days.
I've been thinking of a way to subtract the filling date of a tank from the previous emptying date of said tank, but that does not give me dates. I'm thinking it might not be possible with just a pivot table, maybe a VBA code that loops through all the days, per tank, and registers the ones that don't fall in between filling and emptying dates? What would that look like?
Any ideas? I did find out it seems to resemble some questions related to employee absence days calculations, but I haven't been able to find a suitable solutions.
Thank you in advance,
Allard
This is a snippet from a table in which data is collected from the brewery I work at (not all columns are depicted):
batch # | tank number | brew date | empty date |
22.271 | 17 | 15-08-22 | 30-08-22 |
22.272 | 17 | 15-08-22 | 30-08-22 |
22.273 | 18 | 16-08-22 | 08-09-22 |
22.274 | 18 | 16-08-22 | 08-09-22 |
22.275 | 13 | 17-08-22 | 02-09-22 |
22.276 | 13 | 17-08-22 | 02-09-22 |
22.277 | 4 | 18-08-22 | 01-09-22 |
22.278 | 1 | 19-08-22 | 19-09-22 |
22.279 | 5 | 22-08-22 | 06-09-22 |
22.280 | 6 | 22-08-22 | 06-09-22 |
22.281 | 16 | 23-08-22 | 09-09-22 |
22.282 | 16 | 23-08-22 | 09-09-22 |
22.283 | 15 | 24-08-22 | 07-09-22 |
22.284 | 15 | 24-08-22 | 07-09-22 |
22.285 | 14 | 25-08-22 | 12-09-22 |
22.286 | 14 | 25-08-22 | 12-09-22 |
22.287 | 11 | 29-08-22 | 13-09-22 |
22.288 | 11 | 29-08-22 | 13-09-22 |
22.289 | 12 | 30-08-22 | 16-09-22 |
22.290 | 12 | 30-08-22 | 16-09-22 |
22.291 | 17 | 31-08-22 | 14-09-22 |
22.292 | 17 | 31-08-22 | 14-09-22 |
22.293 | 7 | 01-09-22 | 15-09-22 |
22.294 | 8 | 05-09-22 | 20-09-22 |
22.295 | 4 | 05-09-22 | 19-09-22 |
22.296 | 9 | 06-09-22 | 20-09-22 |
22.297 | 13 | 06-09-22 | 21-09-22 |
22.298 | 13 | 06-09-22 | 21-09-22 |
22.299 | 2 | 07-09-22 | 22-09-22 |
22.300 | 15 | 08-09-22 | 23-09-22 |
22.301 | 15 | 08-09-22 | 23-09-22 |
22.302 | 6 | 09-09-22 | 22-09-22 |
22.303 | 16 | 12-09-22 | 26-09-22 |
22.304 | 16 | 12-09-22 | 26-09-22 |
22.305 | 18 | 13-09-22 | 29-09-22 |
22.306 | 18 | 13-09-22 | 29-09-22 |
22.307 | 3 | 14-09-22 | 27-09-22 |
22.308 | 5 | 14-09-22 | 30-09-22 |
22.309 | 11 | 15-09-22 | 03-10-22 |
22.310 | 11 | 15-09-22 | 03-10-22 |
22.311 | 7 | 19-09-22 | 07-10-22 |
22.312 | 12 | 19-09-22 | 04-10-22 |
22.313 | 12 | 20-09-22 | 04-10-22 |
22.314 | 14 | 20-09-22 | 05-10-22 |
22.315 | 14 | 21-09-22 | 05-10-22 |
22.316 | 8 | 21-09-22 | 10-10-22 |
22.317 | 1 | 22-09-22 | 06-10-22 |
22.318 | 4 | 22-09-22 | 06-10-22 |
22.319 | 17 | 26-09-22 | 12-10-22 |
22.320 | 17 | 26-09-22 | 12-10-22 |
22.321 | 13 | 27-09-22 | 13-10-22 |
22.322 | 13 | 27-09-22 | 13-10-22 |
22.323 | 15 | 29-09-22 | 14-10-22 |
22.324 | 15 | 29-09-22 | 14-10-22 |
22.325 | 2 | 30-09-22 | 17-10-22 |
22.326 | 6 | 30-09-22 | 17-10-22 |
22.327 | 3 | 03-10-22 | 19-10-22 |
22.328 | 9 | 04-10-22 | 19-10-22 |
22.329 | 11 | 05-10-22 | 21-10-22 |
22.330 | 12 | 06-10-22 | 20-10-22 |
22.331 | 12 | 06-10-22 | 20-10-22 |
22.332 | 4 | 10-10-22 | 24-10-22 |
22.333 | 7 | 10-10-22 | 27-10-22 |
22.334 | 14 | 11-10-22 | 25-10-22 |
22.335 | 14 | 11-10-22 | 25-10-22 |
22.336 | 16 | 12-10-22 | 26-10-22 |
22.337 | 16 | 12-10-22 | 26-10-22 |
22.338 | 17 | 13-10-22 | 27-10-22 |
22.339 | 17 | 13-10-22 | 27-10-22 |
22.340 | 8 | 14-10-22 | 28-10-22 |
22.341 | 5 | 14-10-22 | 28-10-22 |
22.342 | 1 | 17-10-22 | 31-10-22 |
22.343 | 13 | 17-10-22 | 01-11-22 |
22.344 | 13 | 17-10-22 | 01-11-22 |
22.345 | 6 | 18-10-22 | 31-10-22 |
22.346 | 15 | 19-10-22 | 02-11-22 |
22.347 | 15 | 19-10-22 | 02-11-22 |
22.348 | 18 | 20-10-22 | 03-11-22 |
22.349 | 18 | 20-10-22 | 03-11-22 |
22.350 | 2 | 21-10-22 | 07-11-22 |
22.351 | 3 | 21-10-22 | 07-11-22 |
22.352 | 11 | 24-10-22 | 08-11-22 |
22.353 | 11 | 24-10-22 | 8-11-22 |
22.354 | 12 | 25-10-22 | 9-11-22 |
22.355 | 12 | 25-10-22 | 9-11-22 |
22.356 | 14 | 26-10-22 | 15-11-22 |
22.357 | 14 | 26-10-22 | 15-11-22 |
22.358 | 16 | 27-10-22 | 14-11-22 |
22.359 | 16 | 27-10-22 | 14-11-22 |
22.360 | 9 | 28-10-22 | 10-11-22 |
22.361 | 4 | 28-10-22 | 16-11-22 |
22.362 | 17 | 31-10-22 | 18-11-22 |
22.363 | 17 | 31-10-22 | 18-11-22 |
22.364 | 7 | 1-11-22 | 16-11-22 |
22.365 | 8 | 1-11-22 | 17-11-22 |
22.366 | 13 | 2-11-22 | 17-11-22 |
22.367 | 13 | 2-11-22 | 17-11-22 |
22.368 | 15 | 3-11-22 | 7-12-22 |
22.369 | 15 | 3-11-22 | 7-12-22 |
22.370 | 18 | 7-11-22 | 22-11-22 |
22.371 | 18 | 7-11-22 | 22-11-22 |
22.372 | 1 | 8-11-22 | 21-11-22 |
22.373 | 2 | 8-11-22 | 21-11-22 |
22.374 | 11 | 9-11-22 | 23-11-22 |
22.375 | 11 | 9-11-22 | 23-11-22 |
22.376 | 12 | 10-11-22 | 25-11-22 |
22.377 | 12 | 10-11-22 | 25-11-22 |
22.378 | 3 | 11-11-22 | 24-11-22 |
22.379 | 5 | 11-11-22 | 29-11-22 |
22.380 | 6 | 14-11-22 | 28-11-22 |
22.381 | 9 | 14-11-22 | 28-11-22 |
22.382 | 16 | 15-11-22 | 1-12-22 |
22.383 | 16 | 15-11-22 | 1-12-22 |
It has columns for batch number, tank number, brew date and tank emptying date. Now, I need to extract the number of days, by month, that a tank is unused, i.e. empty. For example, tank 5 was emptied on the 6th of september, but subsequently filled on the 14th, so it was empty for the 7 days in between. To make things even more complicated (at least to me): if a tank was emptied on a Friday, but filled on a Monday, the weekend shouldn't be considered as unused days.
I've been thinking of a way to subtract the filling date of a tank from the previous emptying date of said tank, but that does not give me dates. I'm thinking it might not be possible with just a pivot table, maybe a VBA code that loops through all the days, per tank, and registers the ones that don't fall in between filling and emptying dates? What would that look like?
Any ideas? I did find out it seems to resemble some questions related to employee absence days calculations, but I haven't been able to find a suitable solutions.
Thank you in advance,
Allard