The generic formula for sample size at a given power in a regression is 

$$
N = \frac{2.84^2}{p(1-p)}\frac{\sigma^2}{MDE^2}
$$

N is your sample size, p is the proportion getting the treatment, $\sigma$ is the standard deviation of the residuals, and MDE=the minimum detectable effect that you are powered for.  2.84 comes from alpha confidence of 95% and 80% power.  

The more explanatory factors you've got in your experiment the more $\sigma$ will shrink.  Knowing how much it will shrink is tricky.  

At some point, analytical formulas collapse, and you're better off simply simulating your entire dataset, multiple times doing some sort of monte carlo, and fitting the desired model to each of the plausible datasets.  Your power is the proportion of times you get the result you want.  As with the analytical methods, you're only as good as your assumptions.  

Source is from memory, roughly following this.

This answer is a verbatim copy/paste of my answer to this thread

Determining sample size for a comparative study involving two unequal groups
I have two types of records: Person and PersonDetail.

Each Person has_one PersonDetail.

I would like to order People based on a field that is in PersonDetail. How do I do that?
