Shopify (SHOP 0.23%) and Veeva Systems (VEEV -0.58%) have crushed the market recently, and both have plenty of potential to continue to do so going forward. Nonetheless, one of these stocks will be a superior investment to the other. Let's see if we can figure out which one.

We'll judge these stocks on the basis of seven criteria, giving each category equal weight.

Two men pulling on opposite sides of rope in front of a dramatic landscape

Image source: Getty Images.

1. Stock appreciation

Over the last five years, Shopify has returned 1,011% to its investors since its initial public offering. Veeva Systems has returned 445% over that same five-year period. The S&P 500, by contrast, only returned 46% in that time span. Both stocks really spanked the market; Veeva Systems did 10 times better than the market, and Shopify did 22 times better.  

Winner: Shopify

2. Rule of 40

Venture capitalists have a quick and dirty method for valuing software-as-a-service (SaaS) companies, particularly when they are fast-growing and unprofitable start-ups. It's a simple calculation: Add a company's profit margin and revenue growth together. If the sum of those two numbers is higher than 40, you have a winner.

Shopify's revenue growth has recently slowed to 44%. While that's still amazing growth, it's only half of our calculation. Unfortunately, Shopify remains unprofitable, with a profit margin of negative 9%. After adding the two numbers together, our "rule of 40" calculation gives us 35, which is not a passing grade.

At 27%, Veeva System's revenue growth is not bad, and its profit margin is terrific, at 30%. Adding those two numbers together gives Veeva a "rule of 40" score of 57. Ding ding!

Winner: Veeva Systems

3. Market cap and total addressable market

Our third criterion is an estimation of how big a company can get. Another way of thinking about this is how high the stock can go. Market capitalization often provides a ceiling for growth, and your stock might start bumping into it. It's harder for a company with a trillion-dollar market cap to double again and again than it is for a much smaller company.  

A company's total addressable market (TAM) can also be a limitation. If a company is going after a small market opportunity, then the upside to the stock is limited. However, if a company is going after a huge market, then your stock growth is open-ended. Keeping TAM in mind can help you avoid niche businesses and instead focus on companies with realistic chances of making 10, 40, or maybe even 100 times your money. 

Shopify and Veeva Systems are both large-cap companies, with market caps of $37 billion and $23 billion, respectively. Veeva provides a SaaS solution for the life sciences industry. The company provides very specific software solutions for pharmaceutical companies and medical device companies. Its software provides solutions that healthcare companies find invaluable in areas like research, clinical trials, and drug sales.

Going after a vertical like this gives Veeva powerful advantages within that vertical, but it also limits the market opportunity. Right now, Veeva Systems only has 719 customers. That's a small number. Veeva estimates its TAM at $9 billion. While Veeva hopes to expand into other industry verticals, like cosmetics and chemicals, right now, the company is clearly a niche business.

Shopify's TAM, on the other hand, is potentially much larger. Any company who wants to do business on the internet is a possible customer. Shopify estimates its market opportunity for small businesses at $70 billion dollars. Shopify also is seeing subscriptions from entrepreneurs who are just starting out as well as large businesses. The market opportunity is vast. Shopify just recently announced that the company had over a million merchants on its network. 

Winner: Shopify

4. Cash and debt

This is an easy one to run down. In the most recent quarter, Shopify had $2.67 billion in cash and $111 million in debt. Subtract the debt from the cash, and Shopify has $2.56 billion in net cash. 

In its most recent quarter, Veeva Systems reported $1.43 billion in cash and $22 million in debt. Subtract the debt from the cash, and Veeva has $1.41 billion in net cash.

Both of these companies have outstanding numbers, but Shopify has over $1 billion more in net cash than Veeva, so we'll call it the winner.

Winner: Shopify

5. Leadership

What we like to see here is a founder-led business, somebody with high insider ownership that gives the founder skin in the game. Leadership really answers the question, "Do I want to invest in this business?" Leadership also defines culture, answering what it would be like to work there. Tobi Lutke is the founder and CEO of Shopify. He has significant ownership stakes in Shopify and is now a billionaire because of his vision and execution. Lutke talks about his company's culture in this fantastic interview.

Peter Gassner is a co-founder and CEO of Veeva Systems. Like Lutke, he's a billionaire now because of his shares in the company he created. According to Forbes, Gassner flies coach and rides a bike to work. Both have strong attributes and lead their companies well. 

Winner: tie

6. Competitive and regulatory threats

Amazon was an early competitor to Shopify, and the e-commerce giant gave up, surrendered, and left the field of battle. Amazon, of course, is a fantastic company that's conquering the world of internet retail. To have Amazon enter your market, try to compete with you, and then run away is impressive

Meanwhile, Veeva Systems has vaulted from the No. 9 company in its life sciences niche (in 2012) to the No. 1 company five years later. It replaced general software offerings from Oracle and SAP with a specific suite of software designed to help pharmaceutical companies. 

Both Shopify and Veeva have impressive mindshare in their respective markets, and though neither company is a monopoly yet, they're both on their way. So far, the Department of Justice hasn't had to file any complaints or tried to break either company up.

Winner: tie

7. Share price and valuation

Shopify shares currently trade at a sky-high multiple of more than 300 times forward earnings. Also, the company's shares are selling for 29 times its revenue, which is also high. 

Veeva Systems sits at a high but still slightly more reasonable 60 times forward earnings, and the company is selling for 23 times its revenue.

Winner: Veeva Systems

And the winner is...

Shopify wins in a squeaker. Both of these companies are outstanding businesses in the SaaS market, which is arguably the strongest of all business models. Companies with high multiples like these often get hit hard during recessions. But make no mistake, these are both powerful businesses and wonderful stocks.