When you’re selling a two-family home, your “cost basis” will determine the taxes you owe.

Q: I am in the process of selling my two-family home I have owned it since 1997. I have done major repairs on the tenant’s apartment and am wondering how do I figure out the amount of the tax I’ll need to pay.

I will be paying off the mortgage with the sale. I am also giving money to my children to use as a down payment for their homes. I think I will have about $200,000 in profit so is the tax based on the original amount I borrowed or the amount I owe now? I refinanced the property many times.

A: To start off, when calculating profit on the sale of a home, the mortgage amount is not considered no matter how many times you refinanced the property.

So if you purchased the home for $250,000 and had a mortgage of $200,000 and later sold the home for $300,000 and your mortgage was paid down to $150,000, you’d ignore the mortgage amounts. What’s relevant is the price you paid for the home, what improvements you’ve made to the home, what it cost to buy the home, what it cost to sell the home and how much money you ultimately got for the sale of your home.

You need to keep track of your purchase expenses. That means that if you paid some fees to buy the home, you can include those fees when you add up what you paid for the home. Some of these fees include title insurance costs, survey expenses, loan expenses that you didn’t deduct way back when and even mortgage broker’s fees if you paid any.

While you owned the home, you might have put on a new roof on the home or put on an addition, installed new appliances, put in a new bathroom or new bathroom fixtures, installed a new furnace or air-conditioning system, or planted trees in your yard. All of these expenses count towards what the home cost you. In IRS terms, all of these expenses are part of your “basis,” sometimes known as the “cost basis.”

Once you compute the basis for the property, you can then figure out what your profit is for federal income tax purposes.

Of course, things can get even more complicated. If the two-family home you are selling was entirely an investment property — that is, you rented both units and neither was your residence — you will have tax to pay when you sell the building. Some of the tax will be in the form of capital gains on the profit from the sale of the building. Another part will be in the recapture of depreciation. You may have received tax benefits from depreciating the building over the many years you owned it. When you add up all the depreciation you took over the years, the IRS will tax you at 25 percent on the depreciation you took in the form a “recapture of depreciation tax.”

To avoid paying any federal income taxes or depreciation recapture taxes now you can sell the property through a IRS 1031 exchange. A 1031 exchange would allow you to sell the building but you’d have to buy a replacement building of at least the same value to defer paying any taxes on the sale.

If you can’t use a 1031 exchange because you need the money, you’ll have to pay the taxes when you sell. One wrinkle is if you live in one unit and not in the other. So you’d have to treat the rental unit as if it was a separate property and the unit you live in as a different property. So, it’s as if you have two sales when you sell the building. On your residence side, the IRS allows you to exclude from federal income taxes (ordinary or capital gains taxes) profit of up to $250,000 if you are single and $500,000 if you are married and the home was your principal residence for 2 out of the last 5 years.

So, if you have allocated 50 percent as your home and 50 percent as your investment property, you probably won’t have anything to pay taxes on the sale of that portion of the building that is your home and you can determine what the profit was on the rental apartment to determine how much profit you’ll have when you sell the building. We hope this information helps and you should talk to a certified public accountant (CPA) or an enrolled agent (EA) about your tax situation.