God told Moses to take several censuses during the Exodus
And the LORD spake unto Moses in the wilderness of Sinai, in the tabernacle of the congregation, on the first day of the second month, in the second year after they were come out of the land of Egypt, saying, Take ye the sum of all the congregation of the children of Israel. Numbers 1:1-2
And the LORD spake unto Moses in the wilderness of Sinai, saying, Number the children of Levi after the house of their fathers, by their families: every male from a month old and upward shalt thou number them. And Moses numbered them according to the word of the LORD, as he was commanded. Numbers 3:14-16
And it came to pass after the plague, that the LORD spake unto Moses and unto Eleazar the son of Aaron the priest, saying, Take the sum of all the congregation of the children of Israel, from twenty years old and upward. Numbers 26:1-2
Solomon had a census (like his father David's) and God didn't mind at all.
And Solomon numbered all the strangers that were in the land of Israel, after the numbering wherewith David his father had numbered them.... 2 Chronicles 2:17
And again the anger of the LORD was kindled against Israel, and he moved David against them to say, Go, number Israel and Judah. ... And David's heart smote him after that he had numbered the people. And David said unto the LORD, I have sinned greatly in that I have done. ... So the LORD sent a pestilence upon Israel ... and there died of the people ... seventy thousand men. 2 Samuel 24:1-17
And David said to Joab and to the rulers of the people, Go, number Israel from Beersheba even to Dan; and bring the number of them to me, that I may know it. ... And God was displeased with this thing; therefore he smote Israel. ... So the LORD sent pestilence upon Israel: and there fell of Israel seventy thousand men. 1 Chronicles 21:2