Sometimes, it's difficult to choose between two stocks. In the case of Home Depot (HD -1.77%) and Procter & Gamble (PG 0.68%), both have successful track records and produced market-beating returns over the last five years.

But that doesn't answer the question of which one will create more wealth for investors in the future. To determine that, let's delve deeper into each company to see which one offers better prospects now.

Someone looking at a chart on a computer.

Image source: Getty Images

Home Depot

Since its founding 45 years ago, Home Depot has grown into the largest home improvement retailer by sales. The company has expanded its reach beyond do-it-yourself customers to professional contractors and those hiring Home Depot to do the work for them.

It's inextricably tied to the housing market, which has boosted results over the last few years. That includes the last fiscal year, which ended on Jan. 29. Same-store sales (comps) grew by 3.1%. The average ticket increased by 8.8%, helped by higher prices and new products.

But transactions fell by 5.4%, with management citing economic factors such as faltering demand due to customers' increased costs. Although February's existing-home sales increased by 14.5%, that snapped a skid of 12 monthly declines.

And with the potential fallout from the banking sector's troubles and economists' predictions of a recession, the housing market (and Home Depot) could feel the effects. This year, the retailer expects flat comps and a decline in earnings per share in the mid-single-digit percentages.

Nonetheless, Home Depot, with its vast selection, has positioned itself well to benefit from the inevitable economic recovery. The board of directors also recently raised the quarterly dividend by 10% to $2.09, and the stock has a 2.9% dividend yield. That's well above the S&P 500's 1.7% yield.

Trading at a price-to-earnings ratio (P/E) of 17, the stock is approaching a valuation not seen since the early days of the pandemic in 2020. It's also lower than the S&P 500's 21 multiple. With an above-average dividend yield, patient investors will undoubtedly be rewarded.

Procter & Gamble

Procter & Gamble, selling everyday necessities like shampoo, deodorant, razors, toothbrushes, detergent, and paper towels, has much less exposure to the economic cycle. And many of these products, sold under brand names like Head & Shoulders, Gillette, and Tide, remain popular with consumers.

Many of these brands have leading market shares. For instance, its razors have over 60% of the global market. The company doesn't sit still, either. Management attempts to stay relevant by focusing on innovation.

While Procter & Gamble has had a lot of success, its latest quarterly results showed some sales weakness. After removing the effects of foreign currency exchange, fiscal second-quarter sales rose by 5%.

But this was entirely due to higher prices, which added 10 percentage points, while volume subtracted 6 percentage points. Product mix added 1 percentage point. It wasn't able to pass along all of the higher costs, with gross margin contracting by 1 percentage point.

Procter & Gamble has built an impressive 132-year dividend history, and has increased its payout for 66 straight years. The stock has a 2.5% dividend yield, but with a P/E of 25, it doesn't appear cheap by historical standards or compared to the overall market.

Based on its lower valuation, I pick Home Depot as the better investment right now. While the economy and housing market might present near-term challenges, I'm confident it will bounce back, as it has in the past.