Walmart (WMT 1.61%) is trading near its 52-week high, and its valuation may look expensive with the stock at a price-to-earnings (P/E) multiple of around 35. But just looking at its trailing earnings won't tell the whole story, nor will it give you a good idea of whether the stock will make for a good investment in the future. If you buy Walmart stock at its current price, it could net you a great return and look cheap in a few years.

Here's a closer look at why this is still a business that's on the cusp of much more earnings growth.

The company is investing heavily in automation

Automation is a big buzzword these days, but for Walmart it means much more than that -- it can result in leaner operations and lower costs, and thus, better profits. At the company's annual investor meeting this month, the big-box retailer forecast that by the end of fiscal 2026 (Walmart's year ends in January), approximately 65% of its stores would have some form of automation and that 55% of the volume that goes through its fulfillment center would go through automated facilities.

The company estimates that by doing this, average unit costs could come down by as much as 20%. It also projects that over the next five years, its sales will average a growth rate of 4%.

These moves will help Walmart as it competes with online retailer Amazon and looks to gain a bigger chunk of the online market. Currently, about 13% of Walmart's sales are from e-commerce, and digital sales were up 17% in the company's fourth-quarter results for the period ending Jan. 31.

By adding automation, Walmart can make the order-taking process more efficient with fewer steps, allowing the business to offer quicker service at a lower cost and be more competitive. One of the problems in recent years, especially amid inflation, is that there has been significant volatility in Walmart's already thin profit margin:

WMT Profit Margin (Quarterly) Chart.

WMT Profit Margin (Quarterly) data by YCharts.

By improving efficiency with automation, the company can achieve better results. Management noted recently that "as the changes are implemented across the business, one of the outcomes is roles that require less physical labor but have a higher rate of pay. Over time, the company anticipates increased throughput per person due to the automation while maintaining or even increasing its number of associates as new roles are created."

Could more layoffs be coming?

In April, the consumer goods retailer also announced that it would be laying off 2,000 employees who work at warehouses that fulfill online orders. And reading between the lines in the company's recent press release does suggest that roles requiring physical labor may not be needed as much as Walmart rolls out automation. It also hinted that it would need different kinds of workers, ones at a higher pay rate (presumably since they may not be entry-level positions that are labor-intensive).

But with higher throughput and efficiency, the net effect should be positive on the company's bottom line. The company's revenue per employee has been rising over the years, but it's still not as high as Amazon's:

AMZN Revenue Per Employee (Annual) Chart.

AMZN Revenue Per Employee (Annual) data by YCharts.

Walmart could be a great buy right now

Walmart's stock price may look a bit expensive today -- the S&P 500 averages a P/E ratio of only 18 -- but the changes it is implementing and the growth it's expecting should improve the bottom line and thus bring down the P/E ratio. Buying shares of Walmart today and hanging on as the business invests in automation and brings down its expenses could be a great move for long-term investors.