NEW YORK (AP) — Dollar Tree and Dollar General reported rising sales in the second quarter as four-decade high inflation drove more customers to bargain chain stores for everything from lightbulbs to groceries.

Dollar stores tend to sell items in small quantities, not big packages, allowing low-income customers to buy a little at a time.

As with previous recessions, higher income shoppers are returning to bargain chains as they trade down to cut spending where they can.

But Dollar Tree and Dollar General are also grappling with rising costs that are rippling through their supply chains. Profits are being squeezed as shoppers narrow their focus on necessities like groceries, which have more narrow profit margins.

Dollar Tree, based in Chesapeake, Virginia, reported second-quarter profits that exceeded expectations though sales were a bit shy of projections. It cut its profit expectations for the year and narrowed its sales projections.

Dollar Tree is still trying to incorporate the Family Dollar business that it acquired in 2015.

“Inflation is at its highest in decades as shoppers are experiencing higher costs related to food, fuel, rent and more,” Richard Dreiling, the company’s executive chairman, said on a conference call Thursday. “Supply chains have been strained and inconsistent. Inventory levels are higher across retail, and consumer shopping patterns continue to zig and zag.”

Dollar Tree Inc. reported a second-quarter profit of $359.9 million or $1.60 per share for the three-month period ended July 30. That compares with $282.4 million, or $1.23 per share in the year ago period.

Wall Street had projected earnings of $1.58 per share, according to Zacks Investment Research.

Revenue was $6.77 billion, which was better than last year, but a sliver short of Wall Street projections.

For the current quarter ending in November, Dollar Tree said it expects revenue in the range of $6.75 billion to $6.87 billion. Analysts surveyed by Zacks had expected revenue of $6.77 billion.

Comparable store net sales for Dollar Tree increased 7.5%. Family Dollar same-store sales increased just 2.0%.

The company now expects full-year earnings to be $7.10 to $7.40 per share, with revenue ranging from $27.85 billion to $28.1 billion. Previously, earnings per share for full-year were expected to be from $7.80 to $8.20. Consolidated net sales for the year were projected to range from $27.76 billion to $28.14 billion.

Neil Saunders, managing director at GlobalData Retail, said that the Dollar Tree is a “tale of two companies.”

“The bad company is Family Dollar, which continues its long run of underperformance,” he said. “At a time when consumers are looking to trade down and save money, we believe Family Dollar should be punching out much better numbers.”

He said that Family Dollar has done nothing to make its stores more attractive and they offer “a somewhat jumbled selection of products”. He said the “dingy and depressing environment in many stores is not conducive to attracting or retaining customers, nor is it helpful for increasing average basket size.”

Dollar General Corp., based in Goodlettsville, Tennessee, reported fiscal second-quarter net income of $678 million, or $2.98 per share, for the three-month period ended July 29. That compares with $637 million, or $2.69 per share, in the year-ago period.

The results surpassed per-share projections from industry analysts of $2.93.

Revenue was $9.43 billion, which also beat Street forecasts and topped last year’s $8.65 billion.

The company now expects same-store sales growth of approximately 4% to 4.5%; up from between 3% and 3.5%.

Dollar General CEO Todd Vasos said that sales of groceries and other consumables were strong, but that was offset by a decline in sales of discretionary goods. The chain is also seeing more high income customers in its stores.

More customers are trading down to private label goods, Vasos said, which tend to be less expensive than national brands.

Shares of Dollar General fell about 1%, or $3.60 per share to $243.85, while Dollar Tree’s shares fell nearly 11%, or $18 to $147.98.