For years, Dollar General (DG -0.41%) has dominated rural retail in the U.S. With discount stores spread around thousands of small towns, the company has insulated itself from the big-name competition mainly operating in large urban areas. This strategy worked beautifully for years with Dollar General's revenue approaching $40 billion in the last 12 months, up over 6,000% since 1990. 

But it is far from happy days for the discount retailer right now. Its stock is going through a major pullback with shares down around 58% from the all-time high set in 2022. Investors are worried about compressing margins, weak sales growth, and encroaching e-commerce competition.

Let's take a deeper dive and see what has brought down shares of Dollar General, and whether these problems are fixable. 

DG Chart

Data by YCharts.

Compressing margins, weak sales growth

After seeing strong expansion during the COVID-19 pandemic, Dollar General's margins have started to fall. In the first six months of fiscal 2023, the company reported an operating margin of 7.49%, down significantly from 9.13% in the prior-year period.

On top of this shrinking profitability, Dollar General is experiencing slowing sales growth. Overall revenue only grew 3.9% year over year in the fiscal second quarter, and that was driven entirely by new store openings. Same-store sales were actually slightly down in the period -- not a good sign for the health of the discount shopper at these stores.

When looking at the longer-term trend, compressing margins is not the end of the world. With a transition to more consumables such as food in its revenue mix, Dollar General's profit margins have trended downward as it reaches greater scale, excluding the pandemic. It is no surprise then to see these margins come back to earth and continue to inch lower as management tries to keep products cheap for customers.

The bigger concern is slowing sales growth. Dollar General is struggling to grow revenue at existing stores, mainly due to declines in apparel and home products. While it's only been two quarters of disappointing results so far, this is enough to strike fear into Dollar General's investor base, which is why the stock is down so much this year. If these weak comparable store sales continue, it will be tough for Dollar General to grow its earnings over the next few years. 

DG Operating Margin (TTM) Chart

Data by YCharts.

Has e-commerce competition finally arrived?

It is tough to pinpoint exactly what is hurting Dollar General today. Some may attribute the stagnant same-store sales to macroeconomic pressure with high gas and food prices eating into its customers' ability to spend on things such as apparel. In the long run, this would be a good thing since it means the company is not losing market share to competitors but facing some short-term headwinds due to factors outside of its control. 

But I think the problems could be a bit more permanent. There is a growing challenge from e-commerce competitors, specifically Amazon as it increases spending on its delivery operations. Today, many Dollar General shoppers can get non-consumable items delivered by Amazon in just a few days. While not as convenient as the same-day and next-day delivery that Amazon can offer in big cities, that is not a major issue for items with a long shelf life. Amazon is partnering with many stores in downtown rural areas to help with package deliveries to these hard-to-reach customers.

There has also been the emergence of Temu from Chinese company PDD Holdings, an online discount retailer that is competing heavily on price with discount stores like Dollar General (excluding food items). The platform has grown explosively over the last year and is the most downloaded app on the two biggest mobile app stores.

Dollar General has been insulated from e-commerce competition for years, but is that insulation becoming exposed ever so slightly? I think it might be.

The stock looks cheap, but that doesn't make it a slam-dunk buy

The good thing about Dollar General is that it already makes the majority of its sales from food items, a category that will be tough for e-commerce to compete with. Consumables made up over 80% of Dollar General's revenue last quarter, and it was the only category with growing sales, albeit with lower profit margins. This should give investors confidence that the e-commerce threat is still somewhat limited to a small chunk of the business.

But increasing consumables revenue should lead to more margin compression. For a business with already low margins, this could have a huge impact on shareholder returns over the next decade. For example, if Dollar General hits $50 billion in revenue within a few years, it will generate about $3.5 billion in operating income if its margin stays near current levels. But if it slides a single percentage point to even 6%, for example, the company will only generate $3.0 billion in operating income, less than what it reported in fiscal 2022. Bottom-line earnings are what drive stock prices over the long haul.

Dollar General has a market cap of about $24 billion as of this writing. That gives it a bargain price-to-earnings ratio (P/E) of 11. With that in mind, the stock can still do well over the long term given how much it has fallen this year and the low valuation, but investors should be wary of how much margin compression eats into Dollar General's earnings power in the years to come.