No business is immune to the negative impact of a recession. Yet consumer staples retailers with wide selling footprints can perform well during downturns. Demand for essential products like groceries and apparel remains relatively stable, after all, even as people reduce spending in areas like travel and dining out.

That fact helps explain why companies like Walmart (WMT -0.80%) and Dollar General (DG 0.63%) are targeting solid sales growth in 2023 even as economic growth rates slow. Let's take a closer look at these retailers to see which is the better fit for your portfolio today.

Market share wins

Both companies are performing well in a challenging selling environment. In late February, Walmart announced that sales rose 8% in the core U.S. market, in part thanks to market share gains in the grocery department. Likewise, Dollar General executives credited increased market share when it revealed 6% comparable-store sales growth in its fiscal Q4.

These results both stand out against the metrics reported by Target (TGT 0.96%), which has seen comps growth trends slow to below 1%. Because they focus on value pricing and consumer staples, Walmart and Dollar General appear positioned for expansion despite challenges around consumer spending trends.

Weaker profits

The short-term earnings outlook isn't especially bright for either retailer. Walmart is predicting no rebound in its operating profit margin after the metric declined in 2022 due to rising costs and unfavorable exchange rate swings. Dollar General recently lowered its earnings forecast, too, but mainly due to the impact of winter weather in the most recent quarter.

DG Operating Margin (TTM) Chart

DG Operating Margin (TTM) data by YCharts

Dollar General remains much more profitable than its bigger rival, though. Its operating margin is above 8%, putting it well above most national retailing peers. Keep in mind that this gap could shrink, especially if shoppers become more price sensitive over the next few quarters. But Dollar General currently has a brighter outlook on the earnings front, with profits likely to grow at a slightly faster pace than revenue in fiscal 2023.

Valuation trends

Investors are being asked to pay a large premium for Dollar General. Shares are trading for 1.4 times annual sales, or about twice the valuation placed on rivals like Walmart and Target. That premium reflects Dollar General's higher profitability, but also its bigger growth opportunity. The retailer sees room to continue adding to its store base, with over 1,000 new locations in the pipeline for 2023. Target and Walmart are more focused on renovating existing stores today.

The above factors make Dollar General a more attractive stock for growth-focused investors who don't mind taking on higher risk. That risk shows up in the retailer's elevated valuation, and in the fact that it has a smaller, more focused selling footprint. Walmart's global scale, on the other hand, would likely help protect returns during the volatility associated with slowing economic growth trends.

But both companies have demonstrated that they can win market share even as consumers become more deliberate about their spending on staples like groceries and snacks. This competitive strength might prove valuable for the rest of 2023.