מדרש אויף במדבר 26:1

וַיְהִ֖י אַחֲרֵ֣י הַמַּגֵּפָ֑ה (פ) וַיֹּ֤אמֶר יְהוָה֙ אֶל־מֹשֶׁ֔ה וְאֶ֧ל אֶלְעָזָ֛ר בֶּן־אַהֲרֹ֥ן הַכֹּהֵ֖ן לֵאמֹֽר׃

און עס איז געװען נאָך דער מגפֿה, האָט גאָט געזאָגט צו משהן און צו אֶלעָזָר דעם זון פֿון אַהרן דעם כֹּהן, אַזױ צו זאָגן:

Sefer HaYashar (midrash)

And at that time, after the pestilence was over, the Lord said unto Moses and Eleazar, the ‎priest, saying: Number ye the heads of the entire congregation of the children of Israel from ‎twenty years and upwards, all those that went forth in the army; and Moses and Eleazar ‎numbered all the children of Israel according to their families, and the number of all Israel was ‎seven hundred thousand and seven hundred and thirty.‎‏ ‏And of the number of the children of ‎Levi from one month and upwards was twenty three-thousand; and there was not among ‎those numbers one man of those that were numbered by Moses and Aaron in the wilderness, ‎for the Lord had said concerning them, that they would all die in the wilderness, and thus not ‎one remained of them, save Caleb, the son of Jephunneh, and Joshua, the son of Nun. After ‎this the Lord spoke unto Moses, saying: Speak unto the children of Israel, that they avenge the ‎cause of their brethren.‎‏ ‏And Moses did so, and the children of Israel selected twelve thousand ‎men from their midst, one thousand from each tribe, and they went unto Midian.‎‏ ‏And they ‎fought against Midian, and they slew every male, and the five princes of Moab and Balaam, ‎the son of Beor, they slew likewise with the sword.‎‏ ‏And the children of Israel captured all the ‎wives of the Midianites, and their children, and their cattle, and alf belonging unto them, and ‎they took all the spoil and all the captives, and they brought them unto Moses and Eleazar, ‎into the plain of Moab.‎‏ ‏And Moses and Eleazar, and all the princes of the congregation went ‎forth to meet them with joy, and they divided all the spoil of Midian, and thus the children of ‎Israel avenged on Midian the cause of their brethren, the children of Israel.‎
פֿרעגט אַ רבֿBookmarkShareCopy

Bamidbar Rabbah

“It was, after the plague; and the Lord said to Moses and to Elazar the son of Aaron the priest, saying” (Numbers 26:1).
“Take a census of the entire congregation of the children of Israel, from twenty years old and above, by their patrilineal house, all those fit for military service in Israel” (Numbers 26:2).

“It was, after the plague.… Take a census” – every place that they fell, they required a census. This is analogous to a wolf that enters in the midst of the flock. The owner of the flock must descend to count how many of them are missing.
Another matter: Why did he count them? This is analogous to a shepherd to whom the owner entrusted his flock by number. The shepherd concluded his watch. When he returns them he must count them. When Israel departed from Egypt, He entrusted them to Moses by number, as it is written: “The Lord spoke to Moses in the wilderness of Sinai.… Take a census of the entire congregation of the children of Israel…” (Numbers 1:1–2). “The children of Israel traveled from Rameses to Sukkot, some six hundred thousand [men] on foot” (Exodus 12:37) – he received them in Egypt by number. [When] he was coming to take his leave of the world in the plains of Moav, he returned them by number.
פֿרעגט אַ רבֿBookmarkShareCopy