Over the past 12 months, Apple (AAPL 0.18%) stock has absolutely trounced the S&P 500, surging 40.4%, from just under $95 per share to about $132 at the time of this writing. This rise compares with the S&P 500's 22% gain during the same period. Interestingly, the performance of Apple's business during this period hasn't been particularly impressive. So, what drove the stock higher?

Boring results

In Apple's most recently reported trailing-12-month period, results actually look quite dismal. During this period, revenue fell 7% and earnings per share tumbled an even steeper 11.3%. Yet Apple stock surged higher.

Apple store in Santa Monica, California.

Image source: Apple.

Sure, Apple's financial results have turned upward recently, with the tech giant reporting 3.3% and 9.6% year-over-year increases in revenue and EPS for the company's most recently reported quarter. But this is just one quarter. Further, these aren't the sort of results often associated with 40% rises in a stock price -- especially when referring to a popular tech company.

But despite Apple's lackluster performance in the past 12 months, shares have climbed higher and easily outperformed the market.

Valuation matters

So if Apple's business saw both revenue and EPS decline in the past 12 reported months, why are shares trading higher? While investors could come up with a range of reasons, one catalyst for the stock during this period likely stands out the most: Apple stock was undervalued.

AAPL PE Ratio (TTM) Chart

AAPL PE Ratio (TTM) data by YCharts

One year ago, Apple stock had a mind-boggling low price-to-earnings ratio of just 10. For context, the average P/E of stocks in the S&P 500 at the time was 21.4, more than double Apple's. Combining this dirt-cheap valuation with Apple's dividend, its sizable repurchase program, and the company's long history of successful products, it was clear that the Street had oversold Apple stock as the market worried about the company's ability to continue growing its business.

Sure, Apple's stock probably didn't justify the same 20 P/E its peers in the S&P 500 averaged, but the stock almost certainly didn't deserve to trade at a P/E of 10.

What's next for Apple stock?

Going forward, can Apple stock continue soaring? While Apple's higher price-to-earnings ratio today of nearly 16 does a better job of pricing in a more optimistic outlook for the company, investors should keep in mind that the stock's 40% rise during the past 12 months doesn't automatically make Apple stock expensive today. Indeed, the stock is arguably still a buy.

For Apple to live up to its valuation today, the company will need to return to more consistent revenue growth and maintain pricing power -- two outcomes that shouldn't be a problem for the company. Yes, revenue and EPS are down in the trailing 12 months, but Apple's return to growth recently, it's fast-growing services segment, and consistently strong pricing power, all point to a bright future for Apple's business -- and a bright future for the underlying business when a stock is trading at just 16 times earnings likely means the stock will perform well, too.