NEW YORK (AP) — Higher income shoppers turned to Walmart looking to cut costs on groceries amid surging inflation, helping to boost sales at the nation's largest retailer during the second quarter.

Those rising prices also led customers to cut back on non-necessary items, however, and that weighed on profits as Walmart was forced to cut prices and clear inventory.

“We’re pleased to see more customers choosing Walmart during this inflationary period,” said CEO Doug McMillon. “The actions we’ve taken to improve inventory levels in the U.S., along with a heavier mix of sales in grocery put pressure on profit margin.”

Walmart still beat Wall Street expectations and sales at stores open at least a year rose 6.5% as more Americans, looking for savings, shopped for groceries at Walmart.

It was more than twice the increase in same-stores sales that the company booked in the first quarter.

And Walmart said it's making progress in getting rid of excess inventory, though it's still an issue. The company on Tuesday said the decline in profit that it forecast just a month ago will be smaller than it thought.

Shares of Walmart jumped nearly 6%.

Walmart Inc., based in Bentonville, Arkansas, is among the first major retailers to report quarterly results and is considered a crucial barometer of spending given its size and the breadth of its customer base.

Walmart shocked Wall Street three weeks ago when it lowered its profit outlook for the first time since 2015 and shares of a company that thrived during the pandemic tumbled 10%.

The warning followed an announcement by Target, another pandemic superstar, in the previous month that it was canceling orders from suppliers as its inventory piled up, untouched by consumers whose shopping patterns shifted rapidly as COVID-19 eased its grip.

Sales of casual clothing, TVs and other electronics that flew off the shelves and into the homes of Americans sheltering in place during the pandemic, went flat as people started going to restaurants, shows or traveling again.

Stubborn inflation, which slowed last month but is still running at close to its highest level in four decades, is also presenting challenges for retailers as low income shoppers cut back.

Those shoppers are buying hot dogs or canned tuna rather than more expensive deli meats, Walmart said Tuesday. Private brand sales in grocery doubled in the second quarter from the first quarter.

Still, Walmart said things got a little better as the second quarter wore on. It saw the influx of new customers, and lower prices offered some relief to shoppers. Strong back-to-school spending helped.

Walmart Inc. earned $5.15 billion, or $1.88 per share, or $1.77 excluding one-time costs and charges. That easily beat the $1.62 per share that Wall Street was looking for, according to FactSet.

It also topped last year's profit of $4.27 billion.

Sales rose 8.4% to $152.86 billion, topping industry analyst projections.

It now expects consolidated adjusted operating income to decline 9% to 11% for the year, an improvement from the company’s prior guidance of 11% to 13%.

Shares rose $7.13 to $139.77 per share in late morning trading.

_____

Follow Anne D’Innocenzio: http://twitter.com/ADInnocenzio

Copyright 2022 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed without permission.