To get the factors you want, start with a complete amortization calculator and a tax deduction calculator, filling in values for your down payment, purchase price, tax rates, and mortgage rate. If you are talking about a specific property, you should be able to get taxes for the current year, and perhaps using historical values estimate taxes going out. Some calculators will include PMI (which you should avoid like the plague in an actual purchase). Given some preliminary data, you can calculate your insurance.
So once you have your PITI (principal, interest, tax, and insurance) monthly payment and tax deduction, you can calculate how much you spend a month on the house minus the deduction.
To estimate maintenance costs, you could either figure out about what you'd need to replace in the given time you plan to stay put and use a rough estimate on what it is. You can also use some rough estimates like this (1% of the property value yearly!) or this (moving the number up to a whopping 2%).
Don't forget closing costs as a buyer and seller. You can find estimates for these as well, and they are a function of the purchase price (usually around 2%).
So to figure out how much it costs you to live in a house for X months, you can do
Sum(PITI - deductions) over the months of owning from the calculators
So your total cost is
down payment + closing costs as buyer + cost per X months + total maintenance cost
Total Return Is:
sale price - closing costs as seller - amount left on mortgage
You can adjust that total return for inflation using this calculator to get your total return adjusted for inflation. If projecting into the future, you can try a formula found here.
To figure out the return on your investment, use
(total return adjusted - total cost) / total cost
So to figure out the total return adjusted you need for a given ROI, find
(ROI * total cost) + total cost = total return adjusted