The calculation is as follows: If you measure ti impact factor of the year 2016 of a journal, than you check the number of citations this journal received by the year 2016 and you divide it by the total number of papers this journal published during 2014 and 2015. This is the calculation of "two years window" because you consider two publication years. The two years' window tend to fluctuate, so sometimes it is preferred to measure the impact with a five years' window which is more stable.
Traditionally, impact value is based on the number of times an article is cited during a specified period after publication. This time frame can be as little as two years or as much as five years. One must also decide what source to use for these citations; usually something like the Science Citation Index (SCI) is preferred. Ideally, one would derive the impact value of a journal based on the mean number of citations actually made to its (relatively recent) articles. But I think Dr. Gordon may be right: that often a short-cut is taken, just dividing the number of citations by the number of articles published in a given timespan.
I know that when you look into this literature, you'll find several ways of estimating impact. All will be variants on the same basic idea, but they can yield somewhat different estimates.
The Impact Factor of a journal is calculated by dividing the number of citations in the JCR year by the total number of articles published in the two previous years.
The Impact Factor is calculated by dividing the number of citations in the Journal Citation Reports (JCR) like that of Thomson Reuters and Web of Science etc. in that year by the total number of articles published in the two previous years. An Impact Factor of 1.0 means that, on average, the articles published one or two years ago have been cited one time. An Impact Factor of 2.5 means that, on average, the articles published one or two years ago have been cited two and a half times.