Could you be a bit more clear with what you need exactly...? Your post sounds extremely cryptic lol ._.
He basically wants it like casting a single-target spell on units in AOE, but capped at a certain amount. It should work similar to the treant spell. You can target many trees, but there is a max number that turn into treants. If you target fewer trees than max number of treants, you get only the number of trees as treants.
However, the treant spell definitely is not how you want to actually implement this. You need a fake AOE spell that only indicates the AOE of the ability. Channel can do this, I believe, but I usually use Death and Decay. 0 duration, 0 damage, no targets allowed. Then I make the AOE the same as the ability I want it to be used for.
In triggers, there is an automatically generated point called "target point of ability being cast". You can use this to determine where the spell is cast. Use a unit group to select the units in range of that point.
Then you have a couple options. To keep it simple, you can just use the "Random unit from unit group" function to pick a random target. Make a dummy unit to cast the spell you want on it and have it cast it. Be sure to remove this unit from the group as well so it doesn't happen more than once.
Repeat as many times as you like. Then destroy the group and all the points created.
If you have little experience with the editor, this will be really hard lol. Let me know if it makes any sense to your or not.