Shares of Walmart (WMT 1.61%) have been on a roll since 2024's stock split, which was its first in over two decades. The stock zoomed up from a 52-week low of $64.16 in May of last year to a high of $105.30 this February.

Then economic uncertainty, exacerbated by U.S. President Donald Trump's tariff policies, sent shares downward. Walmart became one of the biggest retailers to pass tariff-related price increases on to customers, leading Trump to criticize the company for doing so.

Walmart CEO Doug McMillon explained: "We will do our best to keep our prices as low as possible. But given the magnitude of the tariffs... we aren't able to absorb all the pressure given the reality of narrow retail margins."

Despite today's murky macroeconomic picture, there are several reasons why the retail giant is a worthwhile investment over the long run. Here's a look into three of them.

Person holding a shopping basket and examining a product in a store aisle.

Image source: Getty Images.

Walmart's growing e-commerce business

Walmart is already the largest retailer in the world by revenue, and it saw sales grow by 2.5% to $165.6 billion in its fiscal first quarter, ended April 30. Rising revenue is a good sign in this economic environment.

And it's doing even better in its e-commerce division. Online sales soared 22% year over year in its fiscal first quarter. This represented an acceleration over the 16% year-over-year sales increase experienced in the fourth quarter.

Complementing its e-commerce operations is the Walmart Plus membership program, which provides free delivery and other perks for a fee. This service strives to replicate the success of rival Amazon's Prime membership. Growth in subscribers led to a 15% year-over-year increase in Q1 membership income for the company.

Regarding stellar online sales growth, McMillon noted: "It's helpful that we're crossing the threshold of profitability with e-commerce globally, and that we have these newer, higher-margin businesses growing like membership and advertising."

Walmart's strengths in advertising

As McMillon mentioned, advertising boasts robust profit margins, making it another reason to invest in Walmart. Its advertising business experienced a massive 50% year-over-year sales increase in Q1.

Part of the revenue growth is due to the retailer's foray into connected TV (CTV), where it can show ads to customers on the biggest screen in their homes. To that end, Walmart acquired television maker Vizio at the end of 2024. McMillon stated: "This acquisition accelerates the build-out of our advertising platform into the connected TV business."

The move makes sense, since the CTV ad market is expanding rapidly. According to industry forecasts, television advertising will rise annually from 2024's $91 billion to $98 billion in 2027, with CTV accounting for nearly all of that growth.

This tailwind should help Walmart's ad business continue its strong expansion. Because it's a high-margin business, advertising will help Walmart absorb some of the effects of the Trump administration's tariffs.

Walmart's massive free cash flow generation

Walmart's free cash flow (FCF) is another of the company's strengths, one that directly benefits shareholders. FCF provides insight into the cash available to invest in the business, pay debt obligations, repurchase shares, and fund dividends.

The retailer has generated over $10 billion in FCF in the last three fiscal years, and its most recent SEC Form 10-K stated: "[W]e believe our return on capital will improve over time." Walmart kicked off its 2026 fiscal year with FCF of $0.4 billion, representing a nearly $1 billion increase from a negative $0.4 billion FCF in the year-ago period.

The company's healthy FCF enabled Walmart to raise its dividend by 13% in February, eclipsing the prior year's 9% hike, which at the time was the largest increase in over a decade. The retailer has raised its dividend for 52 consecutive years.

Along with the dividend boost, Walmart further rewarded shareholders by spending $4.6 billion to buy back shares in Q1. This is the largest share repurchase done in the past year.

Its FCF, e-commerce, and advertising strengths are just three of the things that make Walmart stock appealing. But is now the time to scoop up shares? To figure that out, here's a comparison of Walmart's forward price-to-earnings (P/E) ratio against Amazon and Costco Wholesale, the second- and third-largest retailers by sales, respectively.

WMT PE Ratio (Forward) Chart

Data by YCharts.

Among these top retailers, Walmart's forward P/E multiple shows that its stock is a far better value than Costco's, and is reasonably priced compared to Amazon, although it's far from the bargain it was a year ago. While you can wait for Walmart stock to dip, another approach is to use dollar-cost averaging to buy some shares now, and continue building your position over time.

Despite the current challenging macroeconomic environment, eventually economic conditions will improve. When they do, Walmart is well-positioned to benefit, making it a worthwhile long-term investment.