Walmart on Thursday reported fiscal first-quarter earnings that topped analysts' expectations despite a recent string of investments weighing on margins.

The world's largest retailer said the results put it in a "good position" to achieve its full-year goals, even though it will face tougher comparisons during the second quarter because of weather-related benefits it reaped in 2018.

Walmart's investments — in its supply chain, grocery business and website — appear to be paying off, as sales continue to climb. And its e-commerce revenues are rising at a rapid pace compared with the industry. Still, first-quarter sales fell short of expectations, impacted by currency headwinds, which dragged on its overseas business.

Walmart shares rose more than 3% by Thursday afternoon, with investors applauding the results.

Here's what Walmart reported compared with what analysts were expecting, based on Refinitiv data:

* Earnings per share: $1.13, adjusted, vs. $1.02 expected

* Revenue: $123.93 billion vs. $125.03 billion expected

* U.S. same-store sales: growth of 3.4% vs. increase of 3.3% expected

Walmart has been pouring money into new technology that helps it fulfill online orders faster, grow its massive grocery business, stock shelves with merchandise and even train its employees. Competing with Amazon online, Walmart just this week announced it is starting to roll out next-day delivery across the country for more than 200,000 items, though it didn't disclose exactly how much money it will be spending to do that. That was after Amazon said on April 25 it will be making free, one-day shipping a new perk for Prime members.

"We're continuing our transformation to become more of a digital enterprise," Walmart CEO Doug McMillon said Thursday in a statement.

E-commerce sales grew 37%, boosted by its home and fashion businesses, Walmart said. That was better than online sales growth of 33% a year earlier, but moderated from a 43% increase during the holiday quarter.