Image Source: Wal-Mart

What: Shares of retail giant Wal-Mart Stores (WMT -0.32%) have surged 20% year-to-date as of market close on July 26, according to data provided by S&P Global Market Intelligence. The stock's 2016 rise has partially reversed a steep decline in 2015 triggered by the company's plan to sacrifice short-term profits in order to increase employee wages and invest heavily in e-commerce.

So what: Wal-Mart first announced plans to raise its minimum wage to $10 per hour in Feb. 2015, along with other initiatives such as improved scheduling for employees and new training programs. The plan is an attempt to improve the in-store experience for customers while reducing employee turnover and boosting morale. These moves come at a cost: Wal-Mart expects its per-share earnings to take a hit and not returning to meaningful growth until fiscal 2019.

WMT Chart

Data by YCharts

This revelation that earnings would decline sent the stock tumbling last year, but positive results so far this year have partially reversed that slump. During the first quarter of fiscal 2017, total revenue rose 4% year-over-year adjusted for currency, while the U.S. business posted its seventh consecutive quarter of positive comparable sales growth. Customer traffic in U.S. stores rose 1.5%, driven in part by the initiatives Wal-Mart is undertaking.

The company is also investing heavily in e-commerce in an effort to compete against Amazon.com. ShippingPass, a 2-day shipping program, is Wal-Mart's answer to Amazon Prime, and the company is expanding its online grocery pickup service in an effort to grow its share of the grocery market. These investments are also contributing to Wal-Mart's reduced earnings.

Now what: Investors punished Wal-Mart stock last year for a short-term reduction in earnings. While the ultimate success of the program is still up in the air, Wal-Mart is getting credit this year for progress growing sales. Shifting exchange rates have been a problem in Wal-Mart's international business, but the U.S. segment is performing well, growing traffic and sales at a time when many other brick-and-mortar retailers are struggling.

The 20% gain so far this year hasn't fully reversed the losses of 2015, but the company's numbers are moving in the right direction, and if earnings return to growth in the coming years, further gains are possible.