Two years ago, Microsoft's (MSFT 0.45%) market cap topped $1 trillion for the first time. On June 24, it ended the trading day with a market cap of over $2 trillion.

A company's market cap, which is calculated by multiplying its number of outstanding shares by its stock price, isn't a useful investing metric on its own. However, it's still remarkable for Microsoft -- one of the world's largest software companies -- to double in value in such a short time.

Let's look back at how Microsoft made the leap from $1 trillion to $2 trillion, and what it would take for the tech giant to cross the $3 trillion mark.

Microsoft CEO Satya Nadella.

Image source: Microsoft.

How Microsoft grew from $1 trillion to $2 trillion

When Satya Nadella became Microsoft's third CEO in Feb. 2014, the company was worth just over $300 billion. At the time, Microsoft was struggling to integrate Nokia's smartphone unit in a desperate bid to save its embattled Windows Phone OS. Its Windows and Office businesses faced uneven upgrade cycles, and many users stuck with outdated versions of its desktop software.

Microsoft also didn't have a significant presence in the growing cloud services market, even as Amazon (AMZN 0.83%) expanded AWS (Amazon Web Services) and salesforce.com (CRM 2.61%) aggressively replaced desktop-based enterprise software with cloud-based services.

In other words, Microsoft had fallen behind the tech curve under Nadella's predecessor Steve Ballmer, who infamously proclaimed there was "no chance" Apple's iPhone would ever succeed.

When Nadella took the helm, he introduced a fresh "mobile-first, cloud-first" mantra. Under his watch, Microsoft ditched Windows Phone and developed mobile apps for iOS and Android instead. It transformed Office's desktop software into cloud-based services, which locked in users with subscriptions, and expanded Azure into the world's second-largest cloud infrastructure platform after AWS.

In 2015, Microsoft launched Windows 10 as the foundation of its "last" desktop OS, which would be continuously updated online and monetized with its app store and additional features. Windows 11, which was recently announced, will be offered as a free upgrade for all Windows 10 users.

The company also launched new Surface devices and Xbox consoles and expanded its gaming ecosystem with subscription-based downloads and a cloud gaming platform.

Between fiscal 2014 and fiscal 2020, which ended last July, Microsoft's commercial cloud revenue -- which primarily comes from Office 365 (now known as Microsoft 365), Dynamics, and Azure -- rose from $2.8 billion to $51.7 billion.

That astounding expansion -- which was fed by big partnerships, investments, and acquisitions (including the purchase of LinkedIn in 2016) -- boosted its total revenue from $86.8 billion in 2014 to $143 billion in 2020. Analysts expect Microsoft's revenue to rise another 16% to $166.2 billion this year.

Nadella's "mobile-first, cloud-first" approach initially squeezed the company's margins, but it clearly paid off and made it an exciting growth stock again. That's why Microsoft is now worth $2 trillion.

How Microsoft can grow from $2 trillion to $3 trillion

Microsoft's market cap doubled between 2017 and 2019, then doubled again between 2019 and 2021. To get to $3 trillion, its stock only needs to rise another 50% -- which could certainly happen within the next two years, for three simple reasons.

A cloud icon placed next to a notebook computer.

Image source: Getty Images.

First, the global cloud services market could still grow at a compound annual growth rate (CAGR) of 16.4% between 2020 to 2027, according to Allied Market Research. If Microsoft keeps pace with the market, its commercial cloud revenue should continue rising at high double-digit percentage rates and account for an even higher percentage of its top line.

Azure will continue to attract customers, especially retailers, as the top alternative to AWS. And the growing need for data storage and AI solutions will tether those customers more tightly to its platform.

Dynamics won't usurp Salesforce as the customer relationship management (CRM) leader, but it will profit from the same secular digitization of businesses. Microsoft 365 should also reinforce its leading position in the productivity software market with its sticky subscriptions. Windows 11 will keep all its users on the same page and enable it to roll out new services as smoothly as Apple and Alphabet's Google.

Second, Microsoft's gaming business will continue to grow as it introduces new Xbox consoles, expands its cloud gaming platform, and acquires more publishers like Bethesda to develop exclusive first-party games. Microsoft could gradually also remove the gaming boundaries between Windows PCs and Xbox consoles with more local streaming and cloud gaming options.

Lastly, Microsoft will continue to expand into next-gen markets. Its HoloLens augmented reality headset, for example, will likely pave the way for new consumer-oriented devices -- which will diversify its hardware business and expand its reach far beyond PCs and mobile devices.

Simply put, Microsoft is no longer in danger of falling behind the tech curve. Nadella steered the company ahead of the curve, and its momentum could propel its valuation past $3 trillion in the near future.