So far, fourth-quarter 2021 earnings have been the story of haves and have nots. Take big tech, for example. Amazon and Alphabet had major beats, while Netflix and Meta Platforms suffered their worst single-day declines (in terms of market cap) in their respective companies' histories.

On Friday, Clorox's (CLX 1.24%) share prices plummeted 14.5% after the company reported worse-than-expected fiscal year 2022 (FY22) second-quarter results. By contrast, Procter & Gamble's (PG 0.68%) stock, another consumer staple company, is hovering around its all-time high as the company continues to put up impressive results in the face of sector-wide challenges.

Here's what separates P&G from Clorox and a look at how to approach investing in each stock now.

Growth outlook

Clorox management said it expects FY22 organic sales to decline by 1% to 4% year over year, its diluted earnings per share (EPS) to decline by 27% to 32%, and its gross margin to be just 36.1% for the coming year, compared to 45%-plus gross margins in FY20 and 43%-plus margins in FY21.

By comparison, P&G is forecasting FY22 organic sales growth of 4% to 5% and diluted EPS growth of 6% to 9%. Clorox blames tough comps as part of the reason for its year-over-year decline, given that the first half of Clorox's FY22 (which was the second half of the 2021 calendar year) lapped the company's banner performance in the second half of the 2020 calendar year. However, P&G follows the same fiscal calendar as Clorox. And so far, P&G is showing it can handle inflation much better than Clorox.

P&G's share prices have outperformed the S&P 500 over the last year, while Clorox shareholders have lost money even when factoring in the dividend.

PG Total Return Level Chart

PG Total Return Level data by YCharts.

Inflation's impact on gross margin

Inflation raises costs, which directly impacts margins. During its Q2 FY22 earnings call, P&G management forecast a $2.3 billion after-tax commodity cost headwind for FY22. In its Q2 2022 prepared remarks, Clorox raised its full-year FY22 commodity cost and transportation expense headwind from $350 million to $500 million.

To put into context how severe Clorox's forecast is, consider that P&G is expecting to generate $76.1 billion in FY22 revenue compared to Clorox's $7.3 billion, making P&G more than 10 times bigger than Clorox from a revenue standpoint. P&G's forecasted commodity cost headwind represents 3.02% of expected FY22 sales, which definitely takes a chunk out of its gross margin.

But that's nothing compared to Clorox's $500 million commodity cost headwind -- which represents 6.9% of its expected FY22 sales. Given the strain of inflation-induced cost pressures, it's no wonder Clorox is expecting a 750-basis-point impact to its gross margin in FY22 compared to FY21.

In sum, P&G is absorbing the added costs of inflation better than Clorox and sustaining top-line organic growth and earnings growth, while Clorox's sales and earnings are on the decline.

The importance of strong free cash flow

Clorox is a Dividend Aristocrat, and P&G is a Dividend King. A Dividend Aristocrat is a component of the S&P 500 that has raised its dividend annually for at least 25 consecutive years, while a Dividend King is an S&P 500 component that has raised its dividend annually for at least 50 consecutive years.

Both companies have a track record for paying and raising their dividends through good times and bad, but P&G is better prepared to support its dividend with free cash flow (FCF). FCF is what's left in operating cash flow after accounting for capital expenditures. Substantially higher advertising costs and inflation left Clorox with just $113 million in FCF for the first half of FY22, far less than the $285 million it paid in dividends.

By comparison, P&G generated $8.27 billion in adjusted FCF in the first half of its FY22, nearly double the $4.35 billion paid to shareholders via the dividend.

P&G expects to pay over $8 billion in dividends to shareholders in FY22 and use excess FCF to buy back between $9 billion and $10 billion of its common stock.

Valuation comparison

At first glance, Clorox stock being well off its highs and P&G stock being the highest it has ever been may give the impression that Clorox is cheaper than P&G. But given Clorox's struggling business and insufficient FCF generation, P&G is much better positioned to handle short- and mid-term challenges.

What's more, Clorox is guiding for FY22 diluted EPS between $3.80 and $4.05, representing a forward price to earnings (P/E) ratio of 36.7. By comparison, P&G is forecasting around $5.90 in diluted EPS, representing a forward P/E ratio of 27.8. So, not only is P&G the better business but also the less expensive stock.

Granted, Clorox expects to turn its business around over the next 12 to 18 months. And if that happens, rapid earnings and increasing FCF could quickly make its valuation look much more attractive. But for now, not even the steep decline in Clorox stock has put the company in the bargain bin relative to its peers.

The better buy now

About the only category in which Clorox has P&G beat is the dividend yield. Clorox's declining stock price has increased its dividend yield to 3.2%, while P&G stock yields just 2.1%. However, long-term investors know that a reliable dividend is always better than a high yield. Given Clorox stock's sell-off, it's not the worst idea to consider the stock if it keeps falling further, especially if management shows it has a better handle on improving gross margin in the coming quarters. But for now, P&G is the better all-around buy.