If you follow Warren Buffett's warning on Walmart stock, you might look past the retailer's earnings pop on Thursday and find better stocks for your money.
Buffett's Berkshire Hathaway is a long-time Walmart shareholder, but in 2016 it sold a large chunk of its stake, then valued around $3 billion. At that time, Buffett cited fellow billionaire Jeff Bezos, Amazon and the pressures ecommerce had created in the retail sector.
Walmart shares have done very well since then. In the second half of 2016, when Berkshire was selling, Walmart was trading near $70. Even though its shares are basically flat so far this year, Walmart is now trading close to $100, with a 10 percent post-earnings gain on Thursday.
Berkshire still held roughly 1.4 million shares of Walmart at the end of June, valued at roughly $140 million. Was it a mistake to get out?
Buffett didn't bash Walmart when he sold — in fact, he had plenty of good things to say about the company. Berkshire's wholly owned retail distributor subsidiary, McLane, has a key business relationship with Walmart. Berkshire bought McLane from Walmart decades ago and still has to negotiate pricing agreements with the retail giant — negotiations that have become even tougher in the Amazon era.
"Walmart is a fabulous company and what Sam Walton and his successors did is one of the great stories of American business," Buffett told CNBC in 2016.
But the investing great stated his case pretty simply in recent years, based on CNBC interviews and Berkshire shareholder meeting commentary culled from CNBC's new Buffett archive: Retail is rough as long as Amazon is growing. There are less worrisome ways to put money to work in the stock market:
"Retailing is too tough for me," he said in the 2016 interview after Berkshire sold the majority of its Walmart stake. "I've been in various things in retailing...and got my head handed to me."
He added, "The online thing is very hard to figure out. ... I just decided I would look for a little easier game."
Walmart's earnings report on Thursday did show strength in online sales, but also was a read on the strength of U.S. consumer spending at this moment in the economic cycle and after the tax cuts, which have boosted earnings for other retailers this season, such as Home Depot.
Buffett has remarked in the past on how well Walmart has done in online sales in response to the Amazon threat. A former top Amazon executive, Marc Lore, is now running Walmart's ecommerce business after its acquisition of Jet.com.
One strength in particular that he cited was having stores all over the country that can act as pick-up spots for online customers. This month, Amazon announced a similar grocery pickup service at its Whole Foods stores, following Walmart's lead. Walmart also is integrating its acquisition of India ecommerce company Flipkart.
But speaking to CNBC in 2016, Buffett pointed to a number that scared him: Walmart's total global online sales was roughly in line with the annual gains that Amazon was making. "Worldwide you're talking maybe $12 billion to $14 billion. ... Amazon is having annual gains of numbers like that."
According to a July forecast from consulting group eMarketer, Amazon has over 49 percent of the U.S. online retail market. It estimated Walmart's share at 3.7 percent, slightly below the share held by eBay and recent Buffett stock buy Apple, at 3.9 percent.
Back in 2015, well before he sold most of the stake, Buffett was clear about the threat Amazon presented. "Ecommerce has to be enormously important to them, it's a game that they've got to become very, very competitive in."
Walmart said U.S. online sales climbed 40 percent during the second quarter, and the company is still anticipating an increase of 40 percent for the full year. But that is down from a 50 percent jump logged in the third quarter of last year.
When asked by CNBC at a time when Walmart was exerting pricing pressure on suppliers like McLane, Buffet remarked on similarities between Walmart and Amazon, similarities which have favored Amazon in the past decade.
"Just as Walmart was once totally underestimated by the seers of its time, the idea some guy in Bentonville, Arkansas, would would take them to cleaners, that was the situation at first with traditional retailers, and Amazon. You want to be underestimated at first."
"Jeff Bezos has built extraordinary economic machine from standing still, a start of zero, with competitors with lots of capital."
Buffett once said one of his biggest investment mistakes — along with never investing in Amazon — was not investing more in Walmart when he had the opportunity. Berkshire first bought Walmart stock in the range of $23 and Buffett over the years has commented several times on the "thumb-sucking" that kept him from buying more as the price rose, a "mistake" he estimates cost Berkshire $10 billion.
Buffett explained back in 2004 that he set out to buy 100 million shares pre-split of Walmart at about $23, and then the stock moved up a little and he thought maybe it would come back down. "That thumbsucking reluctance to pay a little more, the current cost is in the area of $10 billion."
By 2015, Buffett said in an interview with CNBC that lost opportunities in Walmart stock could have made Berkshire $50 billion larger.
"We blew it. It was a total cinch," Berkshire vice chairman Charlie Munger said at last year's Berkshire shareholder meeting.
But Buffett wasn't bothered by the the failure to buy more of Walmart when it was much younger, and it is hard to say whether he would be bothered by Walmart's gains since Berkshire sold it any more than he frets over his inability to buy Amazon shares.
"I should have bought long ago, but I didn't understand the power of the model and the price always seemed more than the power of the model. I missed big time," the Berkshire CEO told CNBC in 2016.
What Buffett has said about Walmart's problem hasn't changed: "They've got a tough competitor."
Walmart shares are up almost 25 percent in the past year. Amazon's stock has climbed more than 93 percent over the same time period.
To learn more about Warren Buffett's views on the markets, investing and stocks, consult CNBC's new Warren Buffett archive.