Salesforce.com (CRM -0.18%) and Veeva Systems (VEEV -0.29%) share a lot in common, and it goes far beyond the fact that these two have pioneered the software-as-a-service (SaaS) business model. 

Peter Gassner -- Veeva's founder and CEO -- was an executive at Salesforce when he realized the cloud needs of the pharmaceutical industry were so specific that they needed a tailored solution. At the time, Salesforce couldn't provide that. So, Gassner decided to start Veeva to address the situation.

A computer chip elevated from a motherboard with a cloud icon on it

Image source: Getty Images.

Both have experienced a lot of success and have rewarded shareholders accordingly. Today, we're going to ask the question: Which stock is the better buy today?

It's not a question we can ever answer with certainty. We can only check back three years from now and see if we were right. To guide us toward an "answer," we'll compare these companies on three different measures.

Financial fortitude

First is financial fortitude. If a financial crisis were to hit tomorrow, how would it affect these companies? Believe it or not, companies with lots of cash, no debt, and strong free cash flow can actually benefit from a recession. 

How? Well, a company can acquire start-ups at discounted prices, it can buy back its own shares, or it can simply outspend the competition into bankruptcy. While that may hurt in the short run, when the economy recovers, the company will have more market share to grab.

Keeping in mind that Salesforce is valued at six times the size of Veeva, here's how the two companies' financials stack up.

Company Cash Debt Free Cash Flow
Salesforce.com $7.7 billion $3.0 billion $3.24 billion
Veeva Systems $1.4 billion $0 $400 million

Data source: Yahoo! Finance. Cash includes long and short-term investments; free cash flow presented on trailing-12-month basis.

These are two companies with stellar balance sheets. Both have healthy cash balances and very strong cash flows. However, if forced to choose one over the other, I'd go with Veeva, in part because it has no long-term debt and in part because -- relative to its size -- it has a more substantial cash position.

Winner = Veeva

Valuation

Next we have to determine if one of these companies is "cheaper" than the other. This is not an exact science. To get a better idea of how "expensive" each stock may be, I like to consult a couple of metrics.

Company P/E P/FCF PEG Ratio
Salesforce.com 56 44 3.0
Veeva Systems 78 57 3.8

Data sources: Yahoo! Finance, YCharts, E*Trade. P/E presented using non-GAAP earnings.

Again, the companies are fairly close. Consider that the average S&P 500 company trades at a P/E of 23 right now. No matter what stripe of investor you consider yourself, both of these companies are fairly expensive. 

That said, Salesforce is notably less expensive, even after taking growth rates (PEG Ratio) into account.

Winner = Salesforce.com

Sustainable competitive advantages

Finally, we have what I consider to be the most important thing to evaluate: a company's sustainable competitive advantage -- or moat. Over the long run, a moat is what allows a company to continue fulfilling its stated mission while the competition isn't able to make a dent.

Both Veeva and Salesforce benefit -- first and foremost -- from high switching costs. When a company sets up its customer relationship management (CRM) data on Salesforce's platform, it can collect gobs of data. Over time, more and more employees at a company become familiar with the ins and outs of Salesforce's interface. The company's expansion into marketing and service clouds only widens that moat.

Veeva's switching costs are equally high. When a company decides to use Veeva Vault, it can do pretty much everything from collecting data from clinical trials to monitoring if there are any safety concerns with a drug already on the market. All of that data is uber-sensitive, and the prospect of losing some of it in a transition to another provider would be enough to keep many clients with Veeva. The company is also branching out and offering its services to other highly regulated industries, like cosmetics, chemicals, and consumer packaged goods.

In the end, I'm calling this one a tie. Both of these companies have very wide moats.

Winner = Tie

And my winner is...

Both of these companies benefit from wide moats via high switching costs. Veeva has a slightly stronger financial position, while Salesforce has a slightly more favorable stock price.

When there's a tie like this, I normally side with the company that has a wider moat. Here, that's also a tie. My second tie-breaker lands wherever I have my own skin in the game. In this case, that's Veeva -- which accounts for 6% of my real-life holdings, while I don't own any Salesforce shares.

If you can't already tell, though, I don't think you can go wrong investigating either company, as they are both very strong players with a business model (software-as-a-service) that's only growing in importance.