Walmart (WMT 0.48%) shares rallied following the company's first-quarter results, and the stock is now up more than 20% year to date. However, more upside could be in store for the stock.

Let's look at the retail giant's most recent quarterly results and the one thing it can do to continue this rally and take the stock to new heights.

Impressive results

Walmart turned in impressive Q1 results. Its revenue rose 6% to $161.5 billion and its adjusted earnings per share (EPS) climbed 22% to $0.60.

In the U.S., Walmart store sales rose nearly 5% to $108.7 billion, while same-store sales jumped 3.8%. The gains came entirely from an increased number of transactions, as average ticket was flat year over year. E-commerce sales, meanwhile, grew 22%.

Internationally, Walmart sales climbed 12% to $29.8 billion, up nearly 11% in constant currencies. The company credited the strong performance from Walmex (Mexico), China, and Flipkart (India e-commerce), with strength in goods and consumables. International e-commerce sales jumped 19%.

Sam's Club U.S., its warehouse store concept, saw sales rise nearly 5% to $21.4 billion. Same-store sales, excluding fuel, rose 4.4%. Transactions climbed 5.4%, while the average ticket was down -1%. E-commerce sales grew 18%, helped by curbside pick-up and delivery. Membership rose 13% year over year.

Looking ahead, Walmart forecast Q2 sales to rise between 3% to 4.5%. For its full year, it guided for sales to come in at the high end or slightly above its prior guidance of 3% to 4% growth. It is looking for full-year adjusted EPS to be at the high end or slightly above its prior outlook of $2.23 to $2.37.

Given the concerns that some companies have expressed about the economy and consumer spending, particularly from the restaurant industry, this was a strong quarter from Walmart. As the country's largest grocer, the company is clearly benefiting from more people staying home and eating in more often.

Customer in aisle reaching for bottle

Image source: Getty Images.

The one thing that can keep the momentum going

Walmart can keep its momentum going and drive the stock higher by continuing to attract higher-income consumers. The retailer has always done well with lower-income consumers, as it has a long history of using its scale and buying power to drive down prices for its customers. That strategy isn't going to change.

However, the company has been doing a nice job recently of drawing in higher-income customers as well. In fact, on its conference call, Walmart said that it continues to see higher engagement across income cohorts but that upper-income households were accounting for the majority of the gains.

The company's strategy with upper-income consumers is to win them over with convenience through offerings such as pick-up and delivery. It also has added some select items that are doing well, such as fresh food, better quality meats, and fresh produce.

Walmart+ continued to grow by double-digits in the quarter and is a big force is driving upper-income consumers to stores. This membership, which costs $98 annually or $12.95 a month, includes free delivery from stores on orders of $35 or more with items priced the same as they are in the store. It also offers scan-and-go shopping where members can check out on their phones and not have to wait in line. It also has other perks such as a free subscription to Paramount Plus, fuel savings, and free flat tire repairs.

Right now, Walmart is doing a great job of attracting more upper-income customers and given its convenience offerings, I would expect this to continue.

Time to buy the stock

Trading at a forward P/E of about 26.5 times, the stock is trading above the around 20 times P/E it has often traded at in the past.

WMT PE Ratio (Forward) Chart

WMT PE Ratio (Forward) data by YCharts

However, the company has room to grow into its multiple and beyond if it can continue drawing in higher-end consumers and deliver EPS above expectations. At current levels, I think the stock is still an attractive long-term buy and that the retailer's strategy is working.