salesforce.com's (CRM) stock surged 26% to an all-time high on Wednesday after the cloud services company posted its second-quarter earnings. Let's discuss the five top reasons Salesforce attracted a stampede of bulls.

1. Crushing Wall Street's expectations

Salesforce's revenue rose 29% year over year to $5.15 billion during the quarter, beating estimates by $200 million and marking its first quarter of generating over $5 billion in revenue.

Salesforce's core businesses generated double-digit year-over-year growth across the board: Its Sales Cloud revenue grew 13%, its Service Cloud revenue rose 20%, and its Marketing and Commerce Cloud revenue jumped 21%. Its Platform and Other revenue surged 66%, with 41 points of growth coming from Tableau, the analytics firm it acquired just over a year ago.

An illustration of a cloud-based computer network.

Image source: Getty Images.

Salesforce attributed its growth to five main factors: gaining new businesses, generating higher license revenue from its customers, lower-than-expected revenue attrition throughout the coronavirus crisis, favorable foreign exchange rates, and its deal with AT&T (T -0.09%) in the previous quarter.

Salesforce's non-GAAP net income soared 152% to $1.33 billion, or $1.44 per share -- which beat expectations by a whopping $0.77. On a GAAP basis, its net income jumped nearly 29 times over the prior year to $2.63 billion.

2. Accelerating billings growth

Salesforce's billings grew 36% from the prior year to $4.63 billion, beating expectations by about $600 million and accelerating from its 22% billings growth in the first quarter.

That acceleration can be attributed to a shift toward remote work and the increased usage of cloud-based services throughout the crisis. Salesforce also inked new partnerships with PayPal (PYPL -0.16%), which integrated its payments platform into Salesforce's services, and several universities and schools pivoting toward online courses.

3. A record-high operating margin

Salesforce's non-GAAP operating margin expanded 590 basis points from the prior year to a record high of 20.2% during the quarter. On a GAAP basis, its operating margin also expanded 200 basis points to 3.5%, silencing the bears who claimed Salesforce would never generate consistent GAAP profits.

Salesforce plans to ramp up its spending in the second half of fiscal 2021, but it still expects its non-GAAP operating margin to expand 75 basis points for the full year -- up from its prior expectations for flat growth.

4. It raised its full-year outlook

Back in May, Salesforce expected its full-year revenue to rise 17%, its operating cash flow to improve 10%-11%, and its non-GAAP earnings to dip 1%-2%. Those numbers looked stable, but Salesforce warned that unpredictable COVID-19 headwinds could affect its business.

However, Salesforce raised all those estimates in the second quarter. It now expects its full-year revenue to rise 21%-22%, its operating cash flow to increase 12%-13%, and its non-GAAP earnings to grow 24%-25%.

During the conference call, CFO Mark Hawkins declared "both the company and our customers navigated the crisis better than our guidance assumed." However, Hawkins warned that the pandemic wasn't over, and that Salesforce was still navigating the crisis "quarter by quarter."

5. It's still reasonably valued in an expensive sector

At first glance, Salesforce stock looks pricey at 74 times forward earnings and 12 times this year's sales. However, it's actually relatively cheap compared to many of its high-growth peers in the cloud market.

Veeva Systems (VEEV -0.56%), which provides cloud services built on Salesforce's platform to life science companies, trades at over 100 times forward earnings and nearly 30 times this year's sales. Veeva expects its revenue to rise 25%-26%, and for its earnings to grow 14%-16% for the full year.

ServiceNow (NOW -1.89%), which helps companies manage their digital workflows with cloud-based services, trades at nearly 110 times forward earnings and over 21 times this year's sales. Wall Street expects its revenue and earnings to grow 28% and 33%, respectively, this year.

All three of these stocks -- and many other cloud stocks -- are currently trading near their all-time highs. Yet Salesforce's surprisingly reasonable valuation suggests it could still have a lot more room to run.

Is it the right time to buy Salesforce?

Salesforce remains the largest cloud-based customer relationship management (CRM) services provider in the world by a wide margin, and its expanding ecosystem of sales, marketing, and e-commerce services will lock in more customers. It's well-insulated from macro headwinds like COVID-19 and the U.S.-China trade war, and it will profit from the secular shift toward automated business processes and analytics-driven decisions. Those strengths, along with Salesforce's rosy guidance and reasonable valuations, make it a compelling buy even as its stock hovers near all-time highs.