CVS Health (CVS -0.22%) and Walgreens Boots Alliance (WBA 0.57%) are both companies built around massive collections of retail pharmacies, but in terms of their appeal to investors, they're a bit different.

You wouldn't know that just by looking at their total returns over the last 12 months, however; both stocks declined in value, significantly underperforming the market's gain of 22%. But CVS' drop of 21% looks a lot worse than Walgreens' 12% loss. 

So which of these competitors is the better buy, given their recent performance and the projects they've got cooking for future growth? 

Pharmacist in pharmacy consulting screen.

Image source: Getty Images.

Walgreens looks like a value trap

You're probably familiar with Walgreens thanks to its pharmacies, but you should also know about its dividend if you're considering an investment.

With a forward dividend yield of 5.9%, this stock's payout is on the high side. But don't take that to mean this company is a cash machine. It's currently paying out more in dividends than it makes in earnings. So when you're evaluating whether it's a stock you might want to buy, keep in mind that the payout might not be around forever -- unless its fortunes make a turnaround.

In terms of its valuation, Walgreens' price-to-earnings (P/E) ratio is 8.2. That's a lot lower than the market's average P/E of 24, and it indicates that investors broadly expect its earnings to grow significantly more slowly than average. If the market's wrong, it could mean that the stock is priced at a steep bargain. 

But there isn't much to suggest that this company is going to expand at even a moderate pace anytime soon. Over the last five years, its quarterly diluted earnings per share (EPS) fell by an average of 2.7% year over year. Management's plan to reverse that trend is to continue scaling up its efforts to compete in the primary care service market, which includes offering pre-acute, post-acute, and specialty care from stand-alone clinics owned by its recently acquired subsidiaries. 

The catch is that CVS is already competing in that market too, and it offers the convenience of co-locating its clinical resources at its pharmacies, which could be an advantage. In the second quarter, Walgreens' primary care segment added 30% to its sales year over year, topping $1.6 billion in revenue. But given that its top line was $132.7 billion in 2022, that sum won't move the needle even if it can continue to grow at its current pace for quite some time.

Plus, Walgreens' healthcare services aren't yet profitable, and it's unclear when or if they will be. So there's a race against time with pushing its growth segments toward profitability, as its dividend might need to get cut eventually otherwise.

CVS is more likely to be a stable investment

As you can probably gather, Walgreens is fighting to reverse its slow decline. CVS, on the other hand, is trying to accelerate its slow advance. To accomplish that, it's also scaling up its primary care services offered at its in-store clinics, not to mention continuing growth in its health insurance business. Both those efforts are already bearing fruit. 

Its health services segment expanded its sales by 12.6% year over year in the first quarter, generating $44.6 billion in revenue. That's already a decent chunk of its trailing 12-month revenue of $322.4 billion. What's more, it's already providing those primary care services at a small profit. And since the middle of 2013, its quarterly diluted EPS climbed by an average of 13.7% annually, so its decent performance isn't anything new.

With a P/E multiple of 24, CVS' valuation is wholly unremarkable, neither raising alarms nor implying a bargain. Likewise, its forward dividend yield of 3.6% isn't high enough to warrant much discussion, though the company's payout ratio of 75% means that it still has overhead room to sustainably raise the dividend moving forward.

Despite Walgreens' low valuation, the question of which company is the better buy isn't really a contest. Where CVS isn't under serious financial pressure while it goes about executing its grand plans, Walgreens is trying to simultaneously shift its course while struggling to stay afloat. While it's unlikely that either stock will outperform the market, given that their primary pharmacy operations aren't going to be experiencing snappy growth, CVS is by far the better buy.