proverb

What you lose on the swings you gain on the roundabouts.

balance

suggests that

Any setback or negative aspect of a certain situation can be offset or balanced by equally advantageous or positive elements. That can work and vice versa.

similar to

There is no great loss without some gain.