With nearly $650 billion in revenue in its fiscal 2024, Walmart (WMT -0.08%) is the largest retailer in the world, even larger than huge retail businesses such as Amazon and Costco Wholesale. And indeed, Walmart generates the majority of its revenue from selling physical retail products in its more than 10,000 brick-and-mortar store locations.

Walmart stock has underperformed the market over the past decade. However, as the chart shows, returns have still been quite good. If you invested $10,000 in Walmart stock 10 years ago and reinvested dividends, you'd have over $28,000 today.

WMT Total Return Level Chart

WMT Total Return Level data by YCharts

Walmart's top-line growth isn't what it used to be -- revenue was only up 6% year over year in its fiscal 2024 (the period from February 2023 through January 2024). And it's only guiding for single-digit growth again in its fiscal 2025. Even so, Walmart stock continues to gain ground because the company keeps growing its profits -- which is how the stock market tends to work over the long term.

This may be surprising considering that Walmart's retail sales are low margin.  However, retail sales aren't driving the gains in profitability. In its fiscal 2025, management expects 20% of its profits to come from two other sources that investors might not expect.

Two factors driving profit growth for Walmart

In its fiscal 2024, Walmart had $27 billion in overall operating income. And for 2025, the company expects 4% to 6% year-over-year growth. At the midpoint, that would take Walmart's operating income up to $28.4 billion.

Walmart's management went on to say that it expects 20% of its total operating income to come from two sources that you might not expect -- that's $5.7 billion for those keeping score. Walmart's two "mystery" profit sources are global advertising and memberships. And both are high-growth, high-margin opportunities right now.

When it comes to advertising, Walmart has been building out its capabilities over the last several years, developing partnerships with adtech companies such as The Trade Desk and Roku. In its fiscal 2024, Walmart generated a whopping $3.4 billion in advertising revenue, a 28% increase from fiscal 2023.

When it comes to memberships, Walmart has multiple ways to attract consumers. The company operates its warehouse discount chain Sam's Club, which is membership-based. However, it also has a service called Walmart+, helping it compete better with Amazon. And Walmart+ is growing at a double-digit rate as well.

In its fiscal 2024, Walmart's U.S. stores had net sales of $442 billion, which is impressive. But the operating margin for these sales was only 5%. By contrast, digital advertising and subscription memberships are higher-margin opportunities for Walmart. Therefore, I don't think it's any coincidence that its net income is growing faster than its revenue in recent years as these higher-margin opportunities get going.

WMT Revenue (TTM) Chart

WMT Revenue (TTM) data by YCharts

Recent moves show that Walmart is further leaning into these other opportunities to boost profits in coming years as well.

Walmart just announced that it's buying Vizio for $2.3 billion to grow its advertising business -- Vizio sells smart TVs and monetizes users through advertising, like Roku. Furthermore, the company is investing in the automation of its supply chain, which will help its Walmart+ service, considering it offers free delivery.

Investors looking at the surface-level numbers for Walmart might wonder where profit growth is going to come from in the future. But investors willing to dig beneath the surface can see that the company is developing revenue streams that should provide a surprising boost to those profits.

It might not outperform the market over the long term. But I do believe that Walmart stock is poised for more long-term gains thanks to these initiatives.