Costco Wholesale (NASDAQ:COST) has trounced the market over the last 1-, 5-, and 10-year time frames. But what's turned out to be a great stock investment hardly ever seemed cheap during that long rally: The P/E ratio dipped below 23 times earnings just twice in the past decade, in 2009 and 2010. 

COST PE Ratio (TTM) Chart

COST P/E Ratio (TTM) data by YCharts.

Shares aren't currently a bargain by that metric, either. Investors are paying 28 times the $5.09 that this retailer booked in profits over the last 12 months. By comparison, you can pick up Wal-Mart at a trailing P/E of 15 or high-performing Kroger for 20 times earnings right now.

Yet Costco's stock last week caught an upgrade on the basis of a "rare opportunity" for investors to bulk up on shares at a historically cheap valuation. Oppenheimer's Brian Nagel boosted it to the equivalent of a "buy" rating from "hold" while setting a price target of $160 per share. 

Nagel's valuation argument has two parts: (1) that recent earnings have been kept unusually low by short-term issues, making the stock seem more expensive than it really is; and (2) that future earnings could jump due to lower expenses and higher membership fees. These trends create a rare "opportunity in shares for intermediate to longer-term-oriented investors," he wrote in a research note.

Hidden earnings power
It's true that Costco's growth is stronger than the headline numbers suggest. Comparable-store sales fell by 1% last quarter and are only up 2% over the last nine months. But gas prices and foreign exchange swings are having a big impact on those figures. After adjusting for the 30% drop in fuel prices and major swings in foreign currencies, Costco's actual comps growth is 7% through the last three quarters -- above the 6% it booked in each of the prior three fiscal years.

Reported comps also hide the fact that Costco is attracting more shoppers to its average warehouse. The retailer booked 3.5% higher customer traffic last quarter, extending its amazing six-year run at roughly 4% shopper traffic gains. 

Changing profit mix
Meanwhile, Costco's expenses are rising on account of a huge investment in the modernization of its IT systems. As you can imagine, the second-biggest retailer in the U.S. runs some hefty computerized operations on everything from payroll to membership management, from shipping logistics to data security. 

Management's tech overhaul is hurting profits right now. It pushed margins lower last year and is expected to do so again in 2015 and 2016. The project is running over budget and also taking longer than expected. But "the big news is that it is working so far," an executive said in last quarter's conference call. And once the spending is complete, earnings growth should get a solid boost higher, as Nagel points out.

The other driver he sees for profit growth is an eventual membership price hike. It's been almost four years since Costco last tinkered with its subscription fees by raising the cost of both the Gold Star and Executive memberships 10%. The retailer gets most of its operating income from those fees, not product markups, and so any price increase will flow directly to earnings.

Get on board
This stock call makes a good case for Costco being cheaper than its 28 P/E ratio implies. However, Oppenheimer analysts might have jumped on board sooner if they weren't so busy looking for quick triggers that could juice the stock price.

The Wall Street firm notes that Costco has "for a long while represented one of the world's best-run and most powerful retail chains." However, "valuation and lack of a catalyst have kept us on the sidelines despite the chain's operating prowess," Nagel writes.

I'd argue that investors should put more weight on the business' strength and less on short-term valuation and catalyst concerns. Oppenheimer seems to be admitting as much with this stock upgrade, at least indirectly.

Demitrios Kalogeropoulos owns shares of Apple and Costco Wholesale. The Motley Fool recommends Apple and Costco Wholesale. The Motley Fool owns shares of Apple and Costco Wholesale. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.