Your database seems to be in de-normalised format (not tidy in tidy data speak). I suggest to normalize it as a first step.
Then, assuming there are no gaps in months, it should be a simple case of dplyr::lag()
.
For normalizing your data (turning it from wide to long format) consider tidyr::pivot_longer()
.
For an example on dplyr::lag()
identifying duplicates (a bit different from your use case - you need both current and previous value >0, but it is a start) consider this post Remove 3rd iteration of duplicate