Two years ago, few would have likely predicted the course of Walmart's (WMT -0.15%) stock. At that time, the company had beefed up its omnichannel presence to better compete with Amazon (AMZN 1.60%), Costco (COST -1.64%), and other peers.

However, COVID-19-related shutdowns brought unexpected benefits to the company. In addition to having the infrastructure to accommodate online orders and pickups, it derived an extra benefit from the demand for consumer staples and the shutdowns of many small competitors. Now, in a post-lockdown world, can the prosperity continue?

Adult and child shop for clothes in a store.

Image source: Getty Images

How did Walmart stock perform over the last two years?

Walmart stock delivered a return of nearly 17% over the last two years. It earned all those gains between March and November in 2020.

When the pandemic began and societies worldwide went into lockdown, Walmart remained open in most locations. Sales rose as Walmart could provide basic needs while serving online and omnichannel customers who were uncomfortable going into a store.

Still, as societies learned to adapt to the pandemic and vaccinations rose, shopping patterns began to resemble pre-pandemic behavior more closely, and the stock price began to trade in a range. Since August 2020, the stock has risen by less than 8%.

Moreover, Walmart has lagged the S&P 500 total return, which has surged by around 50% over the last two years. While one could argue that Walmart is as safe as they come, the only time Walmart outperformed the total market was at the height of the lockdowns.

A look at Walmart today

The company's financials may have contributed to the stock's relative underperformance. In the first nine months of fiscal 2022, revenue of $416 billion rose by 3% compared with the same period in fiscal 2021. However, net income fell 35% to just over $10 billion during that period. Net losses on the changing value of equity investments and a loss on the sale of Walmart Argentina weighed on earnings.

It also severely curtailed free cash flow. Free cash flow for the first nine months of fiscal 2022 came in at just $7.7 billion, less than half of the $16.4 billion generated during the same period last year.

Nonetheless, the overall results reflect a slowdown from fiscal 2021, when revenue surged by 7% and net income, hampered by rising costs and higher income taxes, fell by 10%.

But amid this slowness, the company continues to project optimism. The company forecasted a 6% gain in comparable sales in fiscal 2022. It also raised earnings guidance, taking its forecast to $6.40 per share, up from prior guidance of $6.20 per share and $6.35 per share.

However, the earnings shortfall may have raised the P/E ratio. This stands at 49, which exceeds Costco's 47 earnings multiple and Target's 16 P/E ratio. Still, its price-to-sales ratio of 0.7 comes in well below both Costco and Target, whose sales multiples exceed one.

Should you consider Walmart stock?

The growth in Walmart stock could easily continue. Historically, the stock has followed the S&P 500's total returns. Nonetheless, over the last two years, Walmart underperformed the indexes except during the height of the lockdowns.

Considering Walmart's lower P/S ratio, it could head higher in the near term. Nonetheless, while it will likely rise, the retail stock will probably fall short of total market performance.