Microsoft (MSFT -1.27%) has had a terrific year so far in 2023, riding the tailwinds of a broader rally in technology stocks. Shares of the tech titan are up 15% so far this year, more than triple the gains of the S&P 500. This is in stark contrast to its performance in 2022, when the stock tumbled more than 28%.

The rally this year came on the heels of the company's stronger-than-expected financial results released on Jan. 24. Microsoft's resilience in the face of macroeconomic headwinds boosted investor confidence that the company can capitalize on a couple of vast and growing opportunities over the coming year.

What does this mean for investors who sat out Microsoft's current rally? Should they buy the stock in anticipation of additional gains or avoid the stock because of its higher valuation and the ongoing meltdown in the personal computer (PC) market? Let's take a closer look.

Person with a young child looking at a laptop at the kitchen table.

Image source: Getty Images.

What's been weighing on Microsoft stock?

Microsoft's strength comes from the diversity of its business, but a big chunk still comes from the PC market -- which has been in a secular decline and hit hard by the downturn. In its fiscal 2023 second quarter (which ended Dec. 31), Microsoft's more personal computing segment -- which has historically accounted for nearly a third of its revenue -- was down 19% year over year to $14.2 billion, marking the second consecutive quarter of year-over-year declines. 

The good news is that the PC market may be near a bottom. Morgan Stanley analyst Erik Woodring cut his 2023 PC estimates again but believes the worst has passed, with the market hitting its trough as soon as the current quarter.  

What could drive Microsoft stock higher?

In addition to a rebound in the PC market, Microsoft has other drivers that could fuel a stock rally.

Chief among those is its cloud infrastructure service, Azure. Microsoft experienced strong market-share gains in the worldwide cloud infrastructure market in 2022, reaching 23%, up from 21% in the preceding four quarters, according to data compiled by Synergy Research Group. In fact, over the past five years, Microsoft has notched the largest share gains in the industry, growing by nearly 11 percentage points since 2017. Given the consistency of the company's market-share increases in recent years, there's every reason to believe that trend will continue.

There's also the matter of ChatGPT and the growing utility of artificial intelligence (AI). Microsoft has invested at least $10 billion in ChatGPT-creator OpenAI and is already working to integrate ChatGPT's capabilities into its Bing search engine. The intent is clear -- to wrest some search-market share from Alphabet's Google, which controls more than 90% of the market -- so even small market-share gains could be big business. Microsoft estimates that every 1% share of the market it gains represents a $2 billion revenue opportunity.

While it's too early to know how successful those efforts will be, the excitement surrounding ChatGPT is palpable. This suggests that fervor could be instrumental in attracting additional search users to Bing.

How to approach Microsoft stock now

Microsoft is currently selling at 31 times trailing earnings and 10 times trailing sales. While value investors might balk at the company's valuation, I'd argue that's a pretty reasonable price to pay for a company that's expected to grow both its revenue and earnings per share by double digits by 2024. 

As I've outlined above, Microsoft has a number of catalysts that could drive its stock significantly higher over the coming months and years. Savvy investors with a stomach for a little volatility should consider buying now, particularly given Microsoft's resilience and its robust long-term prospects in the high-growth areas of cloud computing and AI.