Bamidbar1:49

אַךְ אֶת־מַטֵּה לֵוִי לֹא תִפְקֹד וְאֶת־רֹאשָׁם לֹא תִשָּׂא בְּתוֹךְ בְּנֵי יִשְׂרָאֵל׃

"Only the tribe of Levi you shall not count, and you shall not take their total among the children of Israel.

Bamidbar 1:49

אַךְ אֶת־מַטֵּה לֵוִי

Bamidbar / Numbers 1:49 · Drash

Bamidbar 1:49

אַךְ אֶת־מַטֵּה לֵוִי לֹא תִפְקֹד וְאֶת־רֹאשָׁם לֹא תִשָּׂא בְּתוֹךְ בְּנֵי יִשְׂרָאֵל׃

"Only the tribe of Levi you shall not count, and you shall not take their total among the children of Israel.

Drash דְּרָשׁ

Whoever drew a little near

You took one small step toward someone, and suddenly you were trusted with far more than you expected. Why does one step change so much?

The midrash explains: the Eternal saw that the people would anger Him and all those counted would die in the wilderness, and so He took the tribe of Levi out of that decree. The Levites drew near to Him when Moshe (Moses) called: "Whoever is for the Eternal, to me!", and whoever draws himself a little near is drawn very near. Whoever was tested and found faithful, the Holy One, blessed is He, trusts forever, like Yehoshua (Joshua), who defeated Amalek.

How Midrash Tanchuma (Buber) explain it

Midrash Tanchuma (Buber) Another explanation: "Do not cut off."

And so it says in another place: "Count the sons of Levi" (Bamidbar / Numbers 3:15), and then it says again: "Only the tribe of Levi you shall not count" (Bamidbar / Numbers 1:49). He told him only "among the children of Israel," and did not tell him to take them out of the decree. For the Holy One, blessed is He, foresaw that Israel would anger Him, and He would say to them: "In this wilderness your carcasses shall fall" (Bamidbar / Numbers 14:29). Therefore the Holy One, blessed is He, said: the sons of Levi shall not be under that decree, as it says: "And you shall not take their total among the children of Israel" (Bamidbar / Numbers 1:49).

Why? Because they are Mine: "And the Levites shall be Mine" (Bamidbar / Numbers 3:12). For whoever draws himself a little near is drawn very near. And they drew themselves near when Moshe said: "Whoever is for the Eternal, to me!" (Shemot / Exodus 32:26).

And more than that: "But appoint the Levites over the Mishkan of the Testimony" (Bamidbar / Numbers 1:50). For whoever is tested in a matter and found faithful, the Holy One, blessed is He, trusts forever. So you find with Yehoshua: he was tested with Amalek, and he dealt with him according to the Torah and the commandment, as it says: "And Yehoshua weakened" (Shemot / Exodus 17:13).

The Holy One, blessed is He, said to him: "From your tribe I will raise up the one who will exact payment from Amalek," as it says: "Out of Efrayim (Ephraim), those whose root is in Amalek" (Shoftim / Judges 5:14). What is "out of Efrayim" (מִנִּי אֶפְרַיִם)? Efrayim resolved (מָנָה) in his heart to uproot the seed of Amalek. The Holy One, blessed is He, said to him: "After you, Binyamin (Benjamin) among your peoples." He left it to Shaul (Saul), son of Kish, son of Yemini. He is his servant.

Takeaway

Yehoshua was of the tribe of Efrayim (Bamidbar / Numbers 13:8). He defeated Amalek in the first battle after the exodus from Egypt (Shemot / Exodus 17:13).
The midrash reads the word "out of" (מִנִּי) as "resolved, counted" (מָנָה): the words share the letters mem (מ) and nun (נ).
Shaul, the first king of Israel, was of the tribe of Binyamin, "son of Yemini" (Shmuel I / I Samuel 9:1). He was commanded to destroy Amalek (Shmuel I / I Samuel 15:3).
The last words, "He is his servant," are not explained in the midrash, and their link to what comes before is unclear.