Okta (OKTA 1.21%) and Palo Alto Networks (PANW 4.19%) compete in similar niches, but their stock returns recently couldn't be more different. Okta's shares are down by more than 70% since the start of 2022 as the company struggles to integrate a huge new platform. Palo Alto Networks, meanwhile, is gaining market share and eyeing sustainable profitability for the first time in years.

As you might expect given those divergent operating trajectories, there's a big valuation gap between these businesses. But which one is likely to deliver the best returns from here for patient investors with a multiyear time frame?

Latest market share trends

At first glance, Okta might seem like the better growth stock. Sales were up 43% in its most recent fiscal quarter compared to the 27% increase that Palo Alto Networks reported. Yet Okta's momentum isn't nearly as strong. Sales growth missed management's expectations by a wide enough mark that it lowered its full-year outlook. Palo Alto Networks, meanwhile, raised its fiscal year forecast.

A deeper look into its sales trends shows that Okta might have a prolonged period of weaker growth ahead. It closed on its acquisition of Auth0 in May 2021, but the integration of that business hasn't gone as smoothly as executives had hoped, and they are now reevaluating Okta's potential to reach its target of $4 billion of annual sales by 2026. Palo Alto Networks, meanwhile, which has done a better job at steadily widening its security services portfolio, believes it can expand sales at a 20% rate this year to roughly $7 billion.

Profitability match-up

Palo Alto Networks is also the clear winner when it comes to finances. In its fiscal 2022 Q4, which ended July 31, it achieved profitability for the first time in several years, aided by rising prices and a growing customer footprint.

And while Okta is hoping to eventually reach a free cash flow margin of about 20%, Palo Alto Networks' margins already come in well above that level. Management expects cash flow to land at over 30% of sales this fiscal year, in fact. CFO Dipak Golechha told investors to look for further profitability wins ahead, including a "balance of growth and margin expansion."

Value comparison

It's no surprise that Okta is valued at a steep discount, given its growth and earnings struggles. While investors were paying more than 20 times earnings for the stock as recently as early 2022, its current price-to-sales ratio is below 6 compared to Palo Alto Networks' ratio of 10. That gap could lay the groundwork for better returns if Okta can turn things around. Okta also might sport a more attractive growth potential as it capitalizes on high demand in the network security and digital identity management spaces, as evidenced by its over 40% sales spike.

But most investors will want to watch Okta from the sidelines until there is clearer evidence that its market share trends are improving again. With a shaky sales position in its core services, the company won't be able to fully capitalize on cybersecurity demand over the next several years. Okta's recent stumbles might simply be temporary impacts from a complicated acquisition. But Palo Alto Network already boasts solid sales growth, cash flow, and profitability, so investors might prefer its stock today.