Target (TGT 0.18%) stock was flying higher today after the struggling retailer posted better-than-expected results on the bottom line in its third-quarter earnings report.

The report helped reassure investors that the bottom-line challenges Target faced last year are temporary even as it struggles with weak demand for discretionary items and a spike in theft.

As of 12:22 p.m. ET, the stock was up 17% on the news.

The exterior of a Target store.

Image source: Target.

Target hops over a low bar

Target's third quarter showed sales are still weak in the current environment, but it effectively controlled costs in the period.

Comparable sales fell 4.9% due to a decline in discretionary categories, while sales of frequency categories like beauty were stronger. Overall revenue fell 4.2% to $25.4 billion, which was slightly ahead of the consensus at $25.24 billion.

However, the company reduced inventory by 14%, including 19% in discretionary categories, in order to limit markdowns and boost profits, which helped drive gross margin up from 24.7% to 27.4%. Operating margin increased from 3.9% to 5.2%, and adjusted earnings per share jumped from $1.54 to $2.10, which was well ahead of the consensus at $1.48.

CEO Brian Cornell said: "While third-quarter sales were consistent with our expectations, earnings per share came in far ahead of our forecast. This profit performance benefited from our team's commitment to efficiency and disciplined inventory management."

Challenges are expected to persist

The company's guidance for the key holiday quarter was modest, calling for a mid-single-digit decline in comparable sales and adjusted earnings per share of $1.90-$2.60, which compares to $1.89 in the quarter a year ago and the analyst consensus at $2.22, similar to the midpoint at $2.25.

Target stock still looks undervalued after today's jump, trading at a forward P/E of around 15. If the company can reverse the comparable sales decline, the stock still has a lot of upside potential.