Few would dispute that Walmart (WMT -0.81%) is a solid investment. But a 72% gain over the course of just one calendar year? Many of the market's most attractive growth stocks didn't even fare that well in 2024.

What did the retailer do so differently? Not much, actually. The backdrop just changed, forcing investors to finally recognize how durable this company's been all along.

Playing right into Walmart's hand

To fully understand why Walmart stock did so wall last year, one must go all the way back to 2020. The COVID-19 pandemic was in full swing then, working in the retailer's favor. But by 2021, red flags were waving. Like so many other retailers, this one loaded up on too much inventory in anticipation of a spending rebound that was muted by inflation that ended up lingering far longer than expected. That's why even by mid-2023, Walmart stock was no higher than it was as of late 2020.

Then circumstances changed. In the midst of these inflation-driven headwinds, Walmart's value offering and wide selection eventually made it a go-to shopping option for almost everyone. The retailer's 2023 U.S. same-store sales were up 6.6%, and the growth persisted into calendar 2024. Comparable retailers including Target or Dollar General couldn't match that strength. Indeed, several times since then, Walmart's touted how most of its market share gains have come from households earning in excess of $100,000, a demographic that wasn't exactly the store chain's core customer in the past.

The thing is, these more affluent customers seem to be sticking around, responding to the retailer's efforts to keep them coming back. These measures include perks such as free shipping for Walmart+ members on many of their purchases, but also overhauls of its stores that make them look more like a higher-end department store and less like a warehouse.

Investors are simply responding to the traction Walmart is getting.

That said, a two-and-a-half-year hiatus from any forward progress also left the stock primed for an oversized rally.

Right stock, wrong time

But does this rally have a future? Probably not without having a sizable setback materialize first.

Don't misunderstand. This is probably the new norm for Walmart's business. The coming year's projected sales growth of a little over 4% is healthy against the backdrop of tamed inflation. This growth rate is expected to be matched next year, too. CEO Doug McMillon certainly appears to have his finger on the precise pulse of the consumer market right now. Analysts like the stock, too, with the vast majority of them rating it a strong buy.

Now up more than 80% from its late-2023 low, though, there's simply too much near-term profit-taking potential to tangle with the stock just yet. At least let the dust settle a bit first before venturing into this otherwise attractive prospect.