Section 54 applies when you sell a residential house and buy another within the time limits (purchase within 1 year before or 2 years after, or construct within 3 years). You only need to reinvest the capital gain, not the whole sale value.
Section 54F applies when you sell any other long-term asset and buy a house. Here you must invest the entire net sale consideration to get full exemption; partial investment gives proportionate relief, and you must not own more than one other house.
Both require the new house to be held for 3 years, and amounts not reinvested by the ITR due date can be parked in a Capital Gains Account Scheme to keep the exemption alive.
Section 54EC is a third route: invest the gain (up to ₹50 lakh) in specified NHAI/REC bonds within 6 months.
Indus Tax models 54, 54F and 54EC for your sale and structures the reinvestment to maximise the exemption.

