If you bought shares of coffee giant Starbucks (SBUX -2.43%) just two years ago, you're likely unhappy. The stock has dropped about 15% during this time, whereas the S&P 500 has held steady.

However, if you zoom out further, Starbucks' shareholders are much happier. Five years ago, Starbucks stock traded at about $48 per share. As of this writing, it trades at about $97 per share -- roughly doubling over this five-year time span, compared to the broad market's 63% gain.

SBUX Chart

Data by YCharts.

Starbucks' stock didn't double in value by accident -- understanding the reasons behind those gains can help investors determine where Starbucks stock is headed next.

What's happened at Starbucks

There's a general principle at work in the stock market: When earnings go up for a business, the stock price tends to eventually follow.

Investing great Peter Lynch used to say there were five ways for a company to increase its earnings. But I believe his bullet points can be grouped together and consolidated down to just two: For a company to increase its earnings, revenue needs to go up, or expenses need to come down.

Starting with the first side of this equation, Starbucks' revenue has increased over the last five years. During the first six months of its fiscal 2018 (which ended in early April), the company generated $12.1 billion in net revenues. For comparison, during the first six months of its fiscal 2023, it had $17.4 billion in net revenues -- a 44% increase.

The first side of the equation looks good for Starbucks. But turning to the other side, earnings per share (EPS) for Starbucks have gone down, not up with revenue. In the first half of its fiscal 2018, Starbucks had EPS of $2.05. In the first half of fiscal 2023, it had EPS of $1.53.

Starbucks had two main things working against it over the last five years. First, its gross profit margin went down -- that can easily happen in an inflationary environment. 

SBUX Gross Profit Margin Chart

Data by YCharts.

The second problem for Starbucks is its store operating expenses. In the first half of fiscal 2018, store operating expenses were 29.1% of revenue. But by the first half of fiscal 2023, store operating expense had skyrocketed to 41.9% of revenue.

Between gross margin going down and store operating expenses going up, Starbucks' EPS has declined even though revenue is growing. Therefore, looking at Starbucks stock from an earnings perspective, it's more expensive than it was five years ago -- investors are paying a higher valuation.

That sounds like a problem for Starbucks' shareholders, but there's another piece of context to alleviate fears and give optimism for the next five years.

What could go right for Starbucks from here

I started this article talking about how stock prices tend to go up with earnings growth. However, that hasn't been the case with Starbucks  -- the stock is up, but earnings are down.

The reason for this disparity is that the market also looks forward. The biggest problem for Starbucks has been store operating expenses as a percentage of revenue. I believe the market recognizes that this is likely a temporary problem caused by China. And that problem could soon be over.

Starbucks didn't break out financial information for China by itself five years ago, but looking at financial results over just the past year is enlightening. Over the past year, Starbucks' store count in China has jumped by 10%, but its revenue in China is only up 3%. To put it simply, sales per location in China remains well below normal.

Many restaurant expenses are fixed. Therefore, lower sales per location can lead to an increase in store operating expenses as a percentage of revenue. This brings down profitability in Starbucks' second-largest market.

Only in 2023 has China done away with pandemic-related travel restrictions and testing. The country's policies had been a drag on economic activity, but that's finally over, allowing for businesses in China -- including Starbucks -- to start normalizing operations.

In September, Starbucks' management was already looking ahead to an era of no restrictions in China. In 2025, the company expects to have more than 9,000 locations in the country, up from 6,243 at the end of the second quarter of 2023. In other words, management expects new store growth of over 40%. And with greater economic activity, it expects revenue in China to roughly double.

Higher sales per location should lead to better profit margins for Starbucks in China. Therefore, while the company doubles revenue, its EPS for that market should more than double.

The normalization of Starbucks' profit margins will soon make the stock's valuation look more reasonable, and revenue growth from new stores will provide additional upside for investors today.

I'll stop short of saying that Starbucks stock has a clear path to double over the next five years, but I believe market-beating upside is a strong possibility.