Not understanding the reason for the error and solution to it

Without a small reproducible example, as @jcblum mentioned, it's incredibly difficult (nigh impossible) to say what's going on. If it's a matter of privacy, you can create a dummy dataset that demonstrates the behaviour.

For pointers on making a reproducible example (aka a reprex) specific to the community site, check out the reprex FAQ.