Warren Buffett might be one of the greatest stock investors of all time, but not everything he buys turns out to be a winner.

Berkshire Hathaway (BRK.A -0.76%) (BRK.B -0.69%) bought a major stake in a leading computing brand at the start of last year. Less than two years later, the Oracle of Omaha is selling a good portion of that investment, seemingly taking a loss.

And more share sales may be yet to come.

The Buffett stock getting cut from Berkshire's portfolio

Over a three-week period from Sept. 11 through Oct. 3, Buffett's Berkshire Hathaway sold more than 23 million shares of Hewlett Packard (HPQ -0.46%) valued at over $619 million.

The sales reduce Berkshire's stake in the PC and printer maker by roughly 20%.

It's worth pointing out that this information comes from disclosures required by the U.S. Securities and Exchange Commission (SEC). Shareholders with a stake larger than 10% in any company must disclose any trades in that stock within three business days. That's why we didn't have to wait around for Berkshire's quarterly 13F filing.

But with its last reported HP sale on Oct. 3, Berkshire's stake in the company fell below that 10% threshold. So, it's possible Buffett could continue to sell the shares without having to report those sales. And since we're already in the fourth quarter, we may have to wait until February before we find out if Buffett sold more of Berkshire's position.

Why is Buffett cutting his losses?

Buffett bought the bulk of his shares of Hewlett Packard when it was trading in the mid-30s. He sold his shares at an average price of just $26.84, almost certainly taking a loss.

So, why did Buffett change his tune on HP?

While HP benefited from a surge in demand for its PCs and printers at the start of the pandemic, sales have dropped off a cliff over the past year. Sales over the trailing 12 months have fallen below pre-pandemic levels after HP pulled forward a lot of sales into 2021.

More importantly, the outlook doesn't look that bright.

Chief Executive Officer Enrique Lores warned investors in HP's Q3 earnings release, "the external environment has not improved as quickly as anticipated and we are moderating our expectations as a result."

Indeed, the International Data Corporation (IDC) forecasts an decline of almost 14% in PC sales this year. What's more, it only sees the market rising by 3.7% in 2024. Longer term, it sees a 3.1% growth rate in shipments between 2023 and 2027, but it sees Apple taking market share in that time, especially as Microsoft's support for Windows 10 expires in 2025.

The outlook for printing isn't much better. As more and more businesses push toward a paperless future, and the ability to e-sign documents becomes more common, demand for printers and printer supplies is declining. Still, the global market could grow, led by Asia, with Mordor Intelligence expecting a 4.55% annual growth rate through 2028.

On top of that, macroeconomic factors have been weighing on demand and pushing down prices. As a result, HP has seen its operating margin contract over the past year, falling from 8.6% in Q3 2022 to just 7.2% last quarter. Again, that number is below pre-pandemic levels, and there's no clear sign of a turnaround.

When Buffett bought HP, it was coming off booming, pandemic-driven sales. There was no doubt that it would see a return to normal over the coming years. But sales and profits are falling rather than stabilizing, which makes it a much less appealing investment.

Even with shares trading at a valuation of just 7.4 times next year's consensus-earnings estimate and yielding over 4% with its dividend, it's not the most attractive stock in the market. It's cheap for a reason. There are better investment opportunities, and Buffett is selling his stake to go out and buy those instead.