I have some capital gains and some capital losses. My net is a gain. Can I defer just the losses to a later year or does that only apply if I had a NET capital loss

I have $25,000 in gains and $5,000 in losses for a gain/loss of +$20,000. For my specific purposes it would be better for me to pay taxes on the 25,000 gain this year and apply the 5,000 loss to a future year. How do I do that OR is that not allowed?