In its recently ended 2014 fiscal year, Rite Aid Corporation (RAD -20.53%) made significant progress in returning to sustainable profitability. Through the first three quarters of the fiscal year, the company swung from a pre-tax loss of $69 million in FY13 to pre-tax income of $201 million in FY14, despite higher debt retirement charges.

Rite Aid's better-than-expected profitability has caused the stock to nearly quadruple in the last year.

RAD Chart

Rite Aid 1-Year Stock Chart, data by YCharts.

However, the company seems to be losing steam. While Rite Aid has not reported Q4 earnings yet, its sales performance indicates that it lost quite a bit of market share to top rival Walgreen (WBA -0.93%). This is a troubling sign, and investors should remain cautious ahead of Rite Aid's upcoming earnings report.

Sales under pressure
In February, Rite Aid's front-end (i.e., nonprescription) same-store sales fell 1.8%, while the comparable-store prescription count dropped 1.4%. Overall same-store sales still rose by 1.5%, but it was entirely due to rising costs for prescription drugs.

Rite Aid's sales trends weakened last quarter.

The weak February result capped a soft quarter. For the full quarter, front-end same-store sales decreased 0.7% while the comparable-store prescription count fell 1.8%. This is a significantly weaker performance than what Rite Aid had achieved recently -- through the first three quarters of FY14, front-end same-store sales were flat and the comparable-store prescription count was up 0.2%.

What's wrong here?
To some extent, Rite Aid's soft sales results can be explained by factors like tough year-over-year comparisons and a more mild flu season. However, neither of those things can fully explain Rite Aid's weakening sales.

Walgreen reported a 2% increase in front-end same-store sales for February, along with a 2.2% increase in the comparable-store prescription count. For the full quarter, front-end same-store sales were up 2% and Walgreen's comparable-store prescription count was up 2.4%.

Walgreen is winning back market share from Rite Aid.

Clearly, Walgreen is continuing to regain pharmacy market share that it lost during its dispute with pharmacy benefits manager Express Scripts two years ago. Walgreen has also revitalized its front-end sales since mid-2013 by offering more eye-catching discounts. Both of these trends are starting to hurt Rite Aid in a noticeable way.

Assessing the damage
While Rite Aid's recent sales results don't look particularly good compared to what Walgreen has been posting, its full-year revenue of $25.41 billion still came in near the top of the company's most recent guidance range.

There are two potential worries for investors, though. First, drug prices have been increasing, and Rite Aid can't fully pass those cost increases through to insurance companies and pharmacy benefits managers. Second, Rite Aid may be resorting to bigger front-end promotional discounts in order to keep customers from defecting to Walgreen and CVS Caremark (NYSE: CVS).

Both of these headwinds would show up in Rite Aid's gross margin, rather than its same-store sales results. Until Rite Aid reports its full results later this month, investors can't be sure how much margin Rite Aid is sacrificing in order to hold on to revenue. If Rite Aid's gross margin comes under pressure, the stock could give up much of its recent gains.