The first census was in the 2nd year after leaving Egypt (Numbers 1). The census data is repeated in Numbers 2 with the division totals. The tribe of Levi is documented in Numbers 3. The second census was in the 40th year after leaving Egypt (Numbers 26).
All males aged 20 and over were counted for the nation census. All males aged 1 month and over were counted for the Levite census.
Israel had grown rapidly from ~70 males a little over 200 years earlier. Because of their unfaithfulness in refusing to fight the Canaanites they died in the desert. A similar number of men over the age of 20 (but none over 60) were alive ~40 years later. While every Israelite over the age of 20 died in the desert (Numbers 14), this may not have included the Levites. There was no spy sent from the tribe of Levi (Numbers 13), Levi had previously been zealous for the Lord (Exodus 32), and the Levite Eleazer (Exodus 6:25) entered Canaan (Joshua 17:4). Caleb and Joshua were also excluded from the punishment (Numbers 14:30).
Here are the numbers for the 2 censuses. The number of Levites does not add up; the sum of the 3 clans is 22,300 but the total given is 22,000. It is likely that the total is correct thus there is probably a transcription error for Gershon or Kohath.
|Company||Tribe||Clan||Census 1||Census 2|
|Numbers 1-3||Numbers 26|