To say that I was a fanboy of Whole Foods Market (WFM) would be an understatement. In 2011, I made the company a cornerstone of my family's retirement portfolio -- in a very public way

At one point, my initial investment had more than doubled, and Whole Foods made up over 7% of my family's holdings. But the last 30 months haven't been kind to shareholders, and earlier this year, I sold all of my shares.

The underlying reason for Whole Foods' collapse -- and my decision to sell -- led me to one of the most important investing lessons I've learned: There are few things as important as a company's sustainable competitive advantage. Of course, the devil is in the details. Read below and hopefully you can see what I mean...instead of having to learn the lesson the hard way.

What separated Whole Foods from the pack?

The grocery business is brutal. For every dollar that comes in, a store is doing fairly well if it gets to keep just $0.03 of that as profit. The rest pays for the food, the employees, the rent, the utilities, and everything else that goes into running a store. That's why seemingly small changes in a grocery store's margins can have enormous implications for profitability.

Over the last 10 years, there's no better predictor of where Whole Foods' stock is heading than gross profit margins (revenue minus the cost of goods sold).

WFM Chart

WFM data by YCharts.

The reason that Whole Foods traded hands for over 40 times earnings while competitors like Kroger (KR 1.80%) and Costco (COST -0.24%) had multiples closer to 20 was that Whole Foods' gross margins were so much bigger than everyone else's.

COST Gross Profit Margin (TTM) Chart

COST Gross Profit Margin (TTM) data by YCharts

How could Whole Foods magically do this? Quite simply, its customers were willing to pay a higher premium for their groceries. Whole Foods provided three things that no other major grocer in the nation did:

  1. Access to a wide array of certified organic food.
  2. A shopping experience that was unmatched in both store design and eating-in options.
  3. Opportunities to learn more about where the food came from.

The crazy thing was, however, that even though Whole Foods was marking up its organic goods, its more traditional competitors were apparently marking up their limited organic goods by even more. In an unscientific study I did in the D.C. area in 2011, Whole Foods was anywhere from 12% to 38% cheaper on an apples-to-apples comparison of organic food.

In fact, Whole Foods had such a corner on this small but growing niche that when it decided to acquire Wild Oats in 2008, the Federal Trade Commission (FTC) almost nixed the deal on the grounds that Whole Foods would have a virtual monopoly. Whole Foods did agree to sell the Wild Oats brand in 2009 to settle antitrust allegations.

But therein lay the problem

One of the greatest CEOs of our time -- Jeff Bezos of Amazon -- once said that when he looks at competition, he thinks, "Your margin is my opportunity." In other words, if Bezos sees a business charging a premium for something that could be offered for less, he wants to be the one to jump in and offer that product for less.

Grocers like Kroger and Costco took that sentiment to heart, and started discounting their organic goods rapidly. That helps explain why, when I performed the very same unscientific test just two years later, the price advantage of going to Whole Foods had completely disintegrated. Kroger-owned Mariano's Fresh Market offered up the same fare as Whole Foods for virtually the same price.

Almost overnight, Whole Foods had lost the most important thing it had: its identity as the only national chain that offered organic goods for a competitive price.

Reacting, instead of being proactive

Sadly, it was only after this had taken place that Whole Foods co-CEOs John Mackey (who sits on the board here at The Motley Fool) and Walter Robb began to sense a problem. They started using the phrase "price investments" much more often in quarterly conference calls. That's grocery speak for "lowering the price of goods."

Back in 2010 -- before the competition jumped in wholeheartedly -- Robb showed little concern that other grocers could undercut Whole Foods' premium prices. During an August 2010 conference call, he said:

It's hard not to be enthusiastic about our future. We believe we have struck the right balance between increasing our value offerings and maintaining gross margin. We are improving our price positioning relative to our competition, our efforts are helping to drive sales momentum and we are gaining market share.

That would be one of the last times that Robb would be quite so enthusiastic about value offerings compared to the competition. Four years later -- in June of 2014 -- Whole Foods President A.C. Gallo was trying during a conference call to explain to analysts the new approach to "price investments":

Starting about this time last year, we started to make price investments first in a lot of center store categories, and then about halfway through the year, we made some adjustments, did some experiments with price adjustments in seafood, particularly with farm-raised salmon.

This was a starkly different, and more aggressive, approach than had been taken in years past. And analysts were constantly asking when such an approach would help grow comparable-store sales (comps). From the outside looking in, it seemed like Whole Foods was having a very tough time shedding the "Whole Paycheck" image.

For all of the talk about price investments, there's been little help in Whole Foods' comps. In fact, more management talk about "price investments" during conference calls has generally been an indicator of weaker comps.

Data source: Whole Foods Market. Chart by author, using infogr.am. Note that the 2016 results are just for the first two fiscal quarters; conference call mentions of "price investments" were doubled to reflect this.

Was there really an alternative for management?

To be sure, even if the 2010 versions of Robb and Mackey could have foreseen how things would play out, they would have been caught between a rock and a hard place. They could have continued the conservative pace of "price investments" and reaped the rewards of gross margins that maxed out at 4.3% in 2013.

Or, they could have made hyperaggressive "price investments" coming out of the Great Recession. Such discounting would have made offering organic food much less appealing to the Krogers and Costcos of the world, and they might have been more likely to leave this less-profitable space for Whole Foods to dominate. The company could have also taken on debt to speed up the opening of new stores countrywide.

This, however, would have been a very painful move, and investors would have likely hated it. The stock might have plummeted to the point where shareholders demanded resignations. While our 2016 selves know that this hyperaggressive discounting might have been a better long-term move, we need to remember that back then, we couldn't have imagined just how quickly the competition would catch up to Whole Foods.

The lesson in all of this

In the end, Whole Foods simply doesn't have a sustainable competitive advantage. In my experience, there's nothing more important to the success of an investment than the sustainable competitive advantages of the underlying company.

I have the utmost respect for what Whole Foods has done for our country. We eat better food now, and are much more educated about where it comes from, thanks to Whole Foods.

Unfortunately, the company did such a good job of doing this -- and making so much cash from it -- that the competition caught on. And when it did, there was nothing left for Whole Foods to offer that others couldn't. That's a great thing for Americans looking to eat a better diet, but not so great for Whole Foods shareholders.