If size and market momentum were your only stock-picking criteria, then Walmart's (WMT 1.03%) $800+ billion market cap, nearly $700 billion in annual sales, and recent rally to an all-time high would be all you needed to know.
Kraft Heinz (KHC +0.61%), on the other hand, is less than 4% the size of the retail giant -- by both sales and market cap -- and is currently about 75% below its all-time high hit back in 2017.

NYSE: WMT
Key Data Points
This year alone, through the close of trade on Oct. 29, shares of Walmart are up 14% while Kraft Heinz is down 17%.

NASDAQ: KHC
Key Data Points
What these two American icons do share in common, however, is that they're both members of the typically defensive Consumer Staples sector. It's a group of companies that has been out of favor for most of the year, not only trailing the S&P 500 but all 10 of the other major large-cap sectors as well.
If and when that sentiment turns -- and I believe it will -- and investors are once again interested in "old-fashioned" things like stable earnings, solid dividends, and attractive valuations, then the sluggish ketchup and macaroni and cheese play starts to look a whole lot more attractive than the red-hot retailer from Arkansas.
Define cheap?
Let's start with the gold standard of valuations, the forward P/E ratio.
At 37x expected earnings for the next 12 months, Walmart is not only trading at a premium to the market (24x) and its peers in the Staples sector (20x), but Koyfin data shows it is currently sitting in the 98th percentile in terms of its own forward P/E ratio over the past 10 years. That means, since October 2015, you would have been able to buy Walmart at a lower P/E 98% of the time.
On the flipside, Kraft Heinz is trading at just 9.6x forward earnings, less than half the market and sector averages, and with a 2nd percentile P/E rank, it is about as cheap as it has been in a decade.
Moving on to the price-to-sales (P/S) ratio -- the comparison gets a little quirky, as both Walmart and Kraft Heinz have similar P/S ratios of 1.1x and 1.2x, respectively. What's noteworthy, though, is that in Walmart's case, that seemingly low P/S ratio still lands it in the 99th percentile for the past 10 years, while the Pittsburgh-based pickle-maker's comparable P/S rate earns it a remarkable 1st percentile ranking.
Image source: Getty Images.
Continuing our comparisons on a gross profit margin basis, the two companies are, coincidentally, both ranked in the 46th percentile -- i.e., about the middle of their respective 10-year ranges. While this is essentially a draw, it's worth noting that Kraft Heinz's gross profit margin is about 34%, whereas Walmart's is roughly 25%.
Lastly, let's look at dividends, where Kraft Heinz's 6.5% yield is the third-highest in the consumer staples sector, while Walmart's 0.9% payout is the lowest.
In fairness, Walmart has increased its dividend for 52 consecutive years, while Kraft Heinz has not increased its $0.40 quarterly payout since 2019, when it reduced it by 35% to its current level.
What the pros think
In terms of earnings, Walmart will report its Q3 results the morning of Nov. 20, while Kraft Heinz just reported on Oct. 29.
Over the past five years, while Kraft Heinz has beat or met analysts' EPS estimates 20 out of 20 quarters, its top-line results have either met or missed expectations nine out of 20 times.
For its part, Walmart has beat sales estimates 18 out of 20 times (although it has missed two of the past three reports) while also topping EPS consensus 17 out of 20 times.
Unsurprisingly, Walmart's run to record levels has not gone unnoticed on Wall Street, where 41 out of 43 analysts currently rate it a buy, with an average 12-month price target of $113, which is about 10% above current levels.
For Kraft Heinz, 18 out of 20 analysts rate the stock a hold, with only one buy and one sell, and an average 12-month price target of $29, or a 19% gain -- which excludes dividends.
So, for long-term investors who are possibly mulling a defensive hedge, this should not be taken as a knock on Walmart, but rather a spotlight on the cost and premium you will have to pay to chase a market and sector leader.
That's why, for me, the relative value, higher dividend income, limited downside risk, and defensive nature of food stocks make Kraft Heinz the better stock pick.