Magic formula investing is Joel Greenblatt's method of ranking stocks on two numbers, earnings yield (EBIT divided by enterprise value) and return on capital (EBIT divided by net working capital plus net fixed assets), then buying the 20 to 30 stocks with the best combined rank and rebalancing yearly. To run the screen in Excel, list your universe in one column, pull EBIT, enterprise value, and a return-on-capital figure for each ticker with MarketXLS formulas, rank both columns with RANK(), and sort by the sum of the two ranks. Greenblatt described it in "The Little Book That Beats the Market" (updated as "The Little Book That Still Beats the Market").
Try it in your own spreadsheet
Get the free MarketXLS sample workbook (.xlsx).
No account needed. MarketXLS live data requires a paid plan. Preview workbook
Explore more videos
In short, the higher a company's return on capital and earnings yield, the higher it ranks.
Greenblatt reported that the formula beat the S&P 500 96% of the time in his backtest, with a 17-year average annual return of 30.8%. (Source: GuruFocus discussion of the Magic Formula) Those are his published backtest figures, not a forecast. This article is educational, not investment advice.
The 7 steps of magic formula investing
Step 1: Set a minimum market capitalization
Establish a minimum market capitalization (such as $50 million) to get a list of all stocks that meet the criteria.
Step 2: Exclude utility and financial stocks
Step 3: Exclude foreign companies (American Depositary Receipts)
Step 4: Calculate earnings yield
Greenblatt uses earnings yield to measure how much a business earns relative to the price of the whole business.
Earnings yield = EBIT / Enterprise value
Enterprise value (EV) is the sum of market value of equity (including preferred equity) and net interest bearing debt.
Step 5: Calculate return on capital
Greenblatt defines return on capital as trailing 12-month EBIT (operating earnings before interest and taxes) divided by tangible capital employed.
Using EBIT allows investors to compare the operating earnings of different companies without the distortions resulting from differences in tax rates and debt levels.
Tangible capital employed is measured as the sum of net working capital and net fixed assets.
Return on capital = EBIT / (Net working capital + Net fixed assets)
The return-on-capital expression above restates the EBIT and tangible-capital definitions in this section. For further discussion of the earnings-yield calculation and screening approach, see AAII's Magic Formula explanation.
Step 6: Rank all stocks on both measures and add the ranks
Step 7: Buy the 20 to 30 best-ranked companies
Accumulate 2 to 3 positions per month over a 12-month period.
Greenblatt also recommends rebalancing once per year. When rebalancing, sell losers one week before the one-year mark and winners one week after it. You should also sell close to intrinsic value, or when something cheaper is found. He suggests staying invested for 3 to 5 years.
How to build the magic formula screener in Excel with MarketXLS
MarketXLS returns the inputs for each ticker as cell formulas, so the screen is a table of tickers plus two ranks:
=hf_Earning_Before_Interest_and_Taxes_EBIT("AAPL", 2025) EBIT for the fiscal year
=EnterpriseValue("AAPL") Enterprise value
=ReturnOnInvestedCapitalOneYear("AAPL") Return on invested capital (ROC proxy)
=MarketCapitalization("AAPL") Market cap filter (Step 1)
=Sector("AAPL") Exclude utilities and financials (Step 2)
Formula documentation: hf_Earning_Before_Interest_and_Taxes_EBIT, EnterpriseValue, ReturnOnInvestedCapitalOneYear, MarketCapitalization, Sector
Earnings yield is EBIT divided by enterprise value. Greenblatt's exact return on capital (EBIT over net working capital plus net fixed assets) is not a single MarketXLS function, so return on invested capital is used as a proxy. Rank each column with Excel's RANK() (highest first), add the two ranks, and sort ascending. For a ready-made version with a 30-stock universe and top-10 watchlist, see the Magic Formula screener Excel dashboard.
