Deductions & credits

Investing a profit from one home into another does not affect your tax liability for the gain on the first one. You may be confusing your situation with a 1031 exchange which applies to rental property.