It wasn't surprising that Dillard's (DDS 0.11%) performed poorly in the second quarter of fiscal 2017. After all, department store sales have been falling in recent years. Furthermore, Dillard's hasn't been as diligent about reducing its inventory as rivals like Macy's (M 0.05%) and Kohl's (KSS 0.66%).

Nevertheless, the scale of Dillard's Q2 earnings wipeout was shocking. The company posted a $0.58 per share loss, whereas every Wall Street analyst following the company had expected it to be profitable. This just goes to show that struggling department stores must be more careful than ever to maintain lean inventories.

Dillard's lives on the edge

During Q1, Dillard's reported seemingly solid earnings results. While the company did experience some pressure on sales, gross margin recovered relative to a weak performance in the first quarter of fiscal 2016.

The exterior of a Dillard's store.

Dillard's posted fairly solid results in the first quarter of fiscal 2017. Image source: Author.

Furthermore, Dillard's aggressive share buyback program helped cushion the blow to earnings per share. EPS barely declined, slipping to $2.12 from $2.17 a year earlier. Following the Q1 earnings report, investors initially dumped Dillard's stock amid a big sell-off for the department store sector. However, the stock then rallied more than 80% between mid-May and late July, driven by a massive short squeeze.

However, there was trouble brewing beneath the surface. Although Dillard's posted solid gross margin results in the first quarter, it ended the period with inventory up 4% year over year. Given that Dillard's has reported a long string of sales declines, this inventory increase should have been a big red flag to investors.

Everything comes crashing down

Sure enough, Dillard's paid the price last quarter. While the company reported a modest 1% decline in comparable store sales, gross margin plunged by 235 basis points year over year. (One percentage point equals 100 basis points.)

That's why Dillard's posted a steep loss last quarter, compared to EPS of $0.35 a year earlier. Year to date, EPS has fallen to $1.62, compared to $2.55 in the first half of fiscal 2016.

Additionally, Dillard's free cash flow fell to -$38 million in the first half of 2017 from $46 million a year earlier. Of course, Dillard's tends to generate virtually all of its free cash flow in the fourth quarter. The point is simply that free cash flow is on a downward trajectory, which will eventually put a damper on the company's share buybacks.

Looking ahead, the third quarter could be tough as well -- albeit not as bad as last quarter. Dillard's ended July with inventory up about 2% year over year.

Macy's and Kohl's post better results

Macy's and Kohl's also reported that comparable store sales fell in the second quarter. Kohl's saw a relatively modest 0.4% comp sales decline, while Macy's experienced a steeper 2.5% comp sales decline (including licensed departments within its stores).

Fortunately, both companies have been carefully managing inventory levels in light of their weak sales trends. Kohl's and Macy's both ended the first quarter with inventory down about 2% year over year. As a result, Kohl's gross margin declined just 6 basis points year over year in Q2. Meanwhile, Macy's reported a manageable 55 basis point gross margin decline, despite facing significant headwinds from a wave of discounting in the cosmetics business.

The exterior of a Kohl's store.

Gross margin held roughly steady at Kohl's last quarter. Image source: Kohl's.

Macy's and Kohl's both reported earnings results slightly ahead of analysts' estimates. Adjusted EPS declined about 11% year over year at Macy's, while Kohl's had a slight year-over-year increase in EPS. They both exited the quarter with inventory down year over year, as well.

Somewhat surprisingly, investors still weren't satisfied with Macy's and Kohl's second quarter results. As of noon Thursday, Macy's shares had fallen 9%, while Kohl's stock was down 6%. Still, that was better than Dillard's stock's 14% plunge. There could be even more share price declines ahead for Dillard's unless it quickly gets its inventory back in line.