Last week, shares of Macy's (M 1.19%) topped the $40 mark for the first time since late 2016. This marked the culmination of a massive comeback for Macy's stock, which bottomed at less than $18 in early November. In fact, shares of the department store giant traded for less than $30 just a month ago.

Macy's stock has come back into favor mainly due to a dramatic improvement in its sales trend. The company has achieved two straight quarterly comp sales increases, ending a streak of 11 consecutive declines. A lower tax rate is also helping to boost earnings per share.

M Chart

Macy's Stock Performance. Data by YCharts.

Even after this furious rally, Macy's stock still has more upside. However, for the stock to keep rising, Macy's will need to show that its sales growth initiatives are continuing to gain traction -- and that the company will continue to capitalize on the value of its real estate.

Back to normal

As of last summer, Macy's was projecting that it would earn between $2.90 and $3.15 per share in fiscal 2017 (excluding special items). Nevertheless, Macy's stock fell to a 52-week low of $17.41 in early November, just six times the company's projected full-year EPS.

This absurdly low valuation was a clear sign that investors were skeptical about Macy's ability to hit its 2017 earnings guidance, and even more dubious about its ability to maintain that level of profitability going forward. Bears pointed to Macy's long-running streak of comp sales declines and its reliance on real estate gains to meet its EPS targets as evidence that profit was likely to continue falling.

However, Macy's got comparable-store sales growing again last fall, posting a 1.4% comp sales gain in the fourth quarter. As a result, it reported adjusted EPS of $3.29 for fiscal 2017 (excluding a $234 million asset sale gain for its downtown San Francisco men's store building). This easily surpassed the high end of its guidance range.

Furthermore, federal tax reform reduced Macy's effective tax rate all the way from 37% to around 23.25% for fiscal 2018. Meanwhile, Macy's sales recovery is gaining momentum. Last quarter, comp sales rose 4.2% -- or 1.7%, adjusting for a shift in the retail calendar. Thanks to these tailwinds, Macy's expects to post adjusted EPS of $3.75 to $3.95 this year.

A rendering of the exterior of a Macy's store

Macy's is on track to achieve strong EPS growth this year. Image source: Macy's.

Thus, Macy's stock still trades for less than 11 times earnings, a sizable discount to the broader market. Whereas Macy's shares traded at panic-level valuations for much of 2017, the current stock price reflects a more reasonable discount given the long-term challenges faced by the department store industry.

Maintaining sales momentum is important

For Macy's stock to continue making gains, the company will need to grow its earnings over the next few years. Realistically, that requires steady comp sales increases. Strong sales results tend to drive margin expansion for retailers, by spreading fixed costs over more revenue and helping to keep inventory fresh.

One of Macy's most important sales growth drivers is the national rollout of its Macy's Backstage off-price concept. Macy's will add off-price sections to about 100 more full-line stores this year, roughly tripling the number of Backstage locations. Last year, management stated that stores with Backstage sections had an average sales increase of 7 percentage points relative to similar "control" stores without Backstage outlets.

Macy's CEO Jeff Gennette recently expressed interest in having a Backstage section in every Macy's store. Based on the company's recent experience, that would provide a substantial sales boost. Macy's is also working on other promising growth initiatives, but this one is probably the most impactful.

Further real estate moves could help, too

The other potential catalyst that could drive Macy's stock even higher is evidence that additional big real estate gains are coming in the future. Macy's has sold more than $1 billion of real estate over the past three years. Investors have tended to view the corresponding asset sale gains as one-time in nature.

However, Macy's remaining real estate could be worth close to $20 billion. Management is actively working to monetize some of this real estate without undermining the company's core retail operation. Most notably, this includes capitalizing on the value of the Macy's flagship store in Manhattan.

Macy's is moving very slowly due to the complexity of this 2.2-million-square-foot building and its importance as Macy's flagship location. However, there is clearly an opportunity to make better use of this valuable real estate, most likely by shrinking the size of the Macy's store and selling or leasing the excess space.

Macy's and its partner Brookfield Asset Management are also studying options for additional development on land that Macy's owns, particularly its vast parking fields. This effort may also yield substantial real estate gains over time.

With a still-reasonable valuation of less than 11 times earnings, Macy's stock has plenty of upside. But for the stock to keep rising, Macy's must do more than just show it has stabilized its business. It now needs to convince investors that it can start growing earnings again -- and demonstrate that there are more real estate gains in the pipeline.