Walmart (WMT -0.35%) shares are soaring after a blowout second-quarter earnings report. According to some key metrics, it was the company's best quarter since before the financial crisis.

Comparable sales at Walmart's U.S. stores jumped 4.5% -- the fastest growth in more than a decade -- with solid increases in traffic, average ticket, and e-commerce.  The company also raised its earnings-per-share guidance for the year to $4.95-$5.10 from $4.75-$4.95. However, the most important number in the report may have been Walmart's U.S. e-commerce growth rate, which reached 40% after a lull earlier in the year.

You may remember that Walmart stock plunged after the company's fourth-quarter report back in February. Though overall results were solid in that quarter -- comp sales rose 2.6% in the Walmart U.S. segment -- investors were scared off by a sudden slowdown in e-commerce growth. 

In the key holiday quarter, Walmart's U.S e-commerce sales grew by just 23%, well below the blowout numbers it had posted earlier in the year. (E-commerce revenue jumped 50% in the third quarter and 60% in the second quarter.) Management said that the majority of the slowdown was expected, because Walmart lapped the acquisition of Jet.com, but it also blamed unexpected operational challenges, due in part to inventory management problems during the busy holiday period.  

Despite that slowdown, management projected that e-commerce sales would rise 40% in fiscal 2019, the current year, which would be nearly the same pace as last year's 44% growth. Analysts were skeptical that e-commerce growth would bounce back, which explains why the stock dropped 10% on an otherwise strong earnings report.

For instance, as RBC analyst Scot Ciccarelli said at the time, "It is difficult to ignore the magnitude of the slowdown in e-commerce. ... Management expects the growth rate to ramp back up to the 40%+ range after 1Q, but we suspect this target will be met with more skepticism following 4Q17 results than when it was first laid out to investors several months ago." 

However, CEO Doug McMillon and his team did just that. Management said that e-commerce growth would reaccelerate to 40% by the second quarter. Walmart hit that target right on the nose, thanks in part to the expansion and success of its grocery pickup program. That came after 33% e-commerce growth in the first quarter.

Walmart CEO Doug McMillon talking with two employees in the produce section of a Walmart store.

Walmart CEO Doug McMillon with two employees. Image source: Walmart.

There's a pattern here

McMillion stepped into the CEO role in February 2014, inheriting an aging brick-and-mortar giant that had largely failed to keep up with the changing retail landscape and ignored the rising threat from Amazon.com

By conventional measures, Walmart was still a highly successful company, generating $16 billion in profits annually and rewarding investors with rising dividends each year, as it had become a Dividend Aristocrat. It was opening hundreds of Supercenters each year, unbothered by modestly declining comparable sales and changing consumer shopping habits.

McMillon saw looming trouble and took bold action. The company said in October 2015 that it would change its strategy to invest in higher wages, cleaner and better-functioning stores, and digital operations like e-commerce, rather than its traditional "land-grab" method of blanketing the country with new stores. As a result, management said that earnings per share would decline in the following year (fiscal 2017) by 6%-12%, stabilize in fiscal 2018, and return to growth in fiscal 2019, with an increase of 5%-10%.  

You can probably guess how the market reacted to that news. Investors ran for the hills. The stock had its steepest one-day decrease in 25 years, losing 10%. Shares continued to slide from there, bottoming at a multiyear low around $57.  

Clearly, the market hated the strategy, but it turned out to be just the bitter medicine that Walmart needed. And as the table below shows, management forecast and executed that strategy almost perfectly, as EPS is set to be significantly higher than it was before.

Year Adjusted EPS Year-Over-Year Change
Fiscal 2016 $4.59  
Fiscal 2017 $4.32 (5.9%)
Fiscal 2018 $4.42 2.3%
Fiscal 2019 (guidance) $4.90-$5.05 10.9-14.3%

Data source: Walmart financial reports.

As you can see, Walmart actually beat its own forecast -- albeit with the help of a lower tax rate this year. Still, the guidance was generally accurate, which is a huge sign of management's effectiveness.

If you'd bought the stock after the 2015 plunge, you'd be up 75% today.

Management you can trust

The CEO position is the most important job at a company, but generally speaking, the job is relatively straightforward: Set and execute strategy. 

McMillon has proven time and again he can do that, both with the strategic pivot in 2015 and following the more recent speed bump in e-commerce growth. 

That should give investors confidence as Walmart continues to revamp its strategy and rearrange its portfolio internationally, most recently with its blockbuster $16 billion acquisition of Flipkart.

No company can hit its guidance 100% of the time, but after a quarter of booming comparable sales growth, faster e-commerce growth, and with earnings per share approaching an all-time high, it looks like a mistake to doubt McMillon.

I'd expect the stock to move higher from here as it should get a new round of upgrades from analysts.