As Foolish investors, we're seeking long-term success. That means paying attention not just to a company's operating fundamentals, but to how the market is valuing that company.

Imagine two investors, Anne and Barry. Both of them are interested in buying shares of a coffee company -- we'll call it Starfrancs. Both of them have researched Starfrancs's balance sheet and fundamentals, and they think it's a solid business. Starfrancs is fairly valued at $100, but Anne, who's paying less attention to valuation, buys her shares at $120. Meanwhile, Barry is able to buy them on a dip at just $80 each.

Young man and woman shake hands in business attire in front of a window.

Image Source: Getty Images.

Even though both investors own the same company, Barry positioned himself with a much greater margin of safety in the event that the business doesn't perform as well as expected in the future. Buying the stock at a discount makes it more likely that Barry will benefit from capital appreciation in the stock price as Starfrancs reverts to its fair value.

So we can see it's important to consider fair value when determining whether a stock is worth buying. Let's take a look at pharma giant AbbVie (ABBV 0.98%), which is up 18% over the past year. Has this share price increase taken it past fair value?

AbbVie appears undervalued

In an effort to determine the fair value of AbbVie's shares, we will be using the discounted cash flow, or DCF, model

The DCF model lets you estimate what a company is worth by estimating the sum of its future cash flows based on the previous year of cash flows. If the results are lower than the current share price, the company is likely not worth further consideration. However, results that are higher than the current share price imply a potentially enticing investment.

Here's the formula:

Formula for Discounted Cash Flow

Image Source: Matthew Frankel/Fool.com

As fellow Fool Matthew Frankel writes in the linked article above, "That large symbol at the front of the formula is the Greek letter sigma, and it is used to denote the sum of several quantities. In other words, this symbol tells you to perform a present value calculation for each year's cash flow and then add them all together."

The first input into the DCF model is trailing-12-month (TTM) cash flow per share, though TTM earnings per share (EPS) can also be used. In AbbVie's case, these numbers are about the same. We'll opt to use AbbVie's TTM EPS, which is $11.09.

AbbVie's business is solid -- more on that below -- but as investors, we always want to leave ourselves with a margin of safety in case a company fails to meet our expectations. For that reason, we'll assume earnings growth will be 3% annually over the next five years -- well below the analyst consensus of 4.5%. What's more, while it is likely that AbbVie will deliver some level of earnings growth after that, we'll assume zero growth after five years. 

Finally, we're using 10% -- the S&P's average annual return over the long term -- as our discount rate or required annual total return rate as a benchmark to adequately reward us for our efforts as investors.

We arrive at a fair value for shares of AbbVie of $125.55 a share, which is moderately higher than its current share price of $112.55. From this, we can conclude that AbbVie is undervalued.

A leader in rapidly growing fields

Now that we know its fair value, let's talk about AbbVie's business. Its immunosuppressant Humira was the world's best-selling drug in 2019, and some investors have worried about what will happen when the drug goes off-patent in the U.S. in 2023. But the company has a number of paths, specifically within the oncology and immunology fields in which it is a leader, to stabilize its revenues and earnings.

Oncology and immunology are already the largest segments of the pharma industry by annual spending, and both are poised to benefit from 9% to 12% compound annual growth rates through 2025 (for other areas, that number is 5%). That should bring annual spending in each field to $273 billion and $175 billion, respectively, per FiercePharma.

AbbVie's oncology and immunology segments (which include Humira) comprised about 57% of the company's Q1 2021 revenue. That means the bulk of the company's sales are generated in the two most dominant, fastest-growing areas of pharma. And AbbVie is in a position to offset any near-term declines in Humira revenue with its two other immunology blockbusters, Skyrizi and Rinvoq, which combined saw year-over-year growth in excess of 100% to a combined $900 million in Q1 2021 -- further supporting the notion of massive demand in the immunology field of pharma. Further, AbbVie's two oncology drugs, Imbruvica and Venclexta, saw sales climb 7.3% year over year to a combined $1.7 billion in Q1 2021.

Is AbbVie worth your money?

AbbVie is an industry leader in the rapidly growing oncology and immunology fields. It has a solid dividend of about 4.6% and is well positioned to guard against any loss of revenue from Humira. Its current price of about $113 looks like a moderate discount to fair value, making this company worthy of attention from investors looking to start or add to a position, anywhere below $125 a share.