The prospect of a recession this year has investors looking more seriously at consumer staples stocks. These businesses tend to perform better than other investment sectors, like tech, during downturns because of their focus on essential products like groceries and laundry supplies.

Consumer staples stocks like Walmart (WMT -0.35%) and Procter & Gamble (PG 0.08%) are leaders in their respective industries, making them excellent stocks to consider if you're in the market for stable sales growth and rising dividend income, no matter which way the economy is headed.

Let's compare these two blue-chip giants to see which one might be the better fit for your portfolio.

Recent growth trends

Both companies are in a similar growth position that reflects slowing but still positive sales and market share trends. Walmart's comparable-store sales were up 8% in the core U.S. market last quarter, putting it well ahead of Target and roughly on pace with Costco Wholesale. P&G posted a 5% organic sales boost in the period that ended in late December and has been modestly outgrowing rival Kimberly-Clark over the past full year.

There are signs of stress on both businesses, though. P&G posted a 6% drop in sales volumes as consumers pulled back in response to sharp price increases. Similarly, Walmart had to rely on higher average spending to boost sales in Q4 as customer traffic growth slowed to below 2%.

Cash and earnings

While they each face profitability challenges, P&G is the clear winner in this arena. The company posted an over 21% operating profit margin for the past full year, or roughly 7 percentage points above peer Kimberly-Clark. Walmart, on the other hand, achieved a 3.3% operating margin that put it below rivals such as Target and Costco.

WMT Operating Margin (TTM) Chart

WMT Operating Margin (TTM) data by YCharts

Walmart didn't forecast an impending rebound in the year ahead, and its operating margin is likely to hold steady in fiscal 2024 after dropping sharply last year. P&G is under historic cost pressures, too, with nearly $4 billion of extra expenses hitting the bottom line this year. But its profitability reflects more pricing power and a focus on high-end brands in areas like skin and beauty care.

Outlook and value

Walmart's stock will appeal to investors who are more focused on value than growth. Shares are valued at 0.6 times sales right now, translating into a relative discount compared to both Costco and Target. P&G, on the other hand, is priced at over 4 times sales, compared to Kimberly-Clark's P/S ratio of 2.1.

That premium reflects P&G's stronger financial position, but also its brighter short-term outlook. The consumer staples giant in January projected organic growth of between 4% and 5% this fiscal year, which was a modest upgrade to its prior forecast. Walmart's February forecast called for comps to rise by about 2% this year.

You also get higher dividend income with P&G, which delivers a 2.7% yield today, compared to Walmart's 1.2% yield. Consider that a solid bonus on top of its industry-leading sales and financial metrics.

Unless your focus is just in finding cheaply valued stocks, P&G seems like the clear winner in this stock investment matchup.