If I'm understanding what you're after, this is how I would build the flow.
For this example, I'm using the following SharePoint List where I want to get a certain number of random items.

See full flow below. I'll go into each of the actions.

Manually trigger a flow has a single Number input. This is the number of random items I want to return. If the number of items you wanted was always the same, then you could skip having an input here.

Get items returns all the items from the SharePoint list.

Select uses the output from Get items and Maps the ID field and another custom field called Order that uses the rand function to generate a random number for each item. The expression used is below.
rand(1, 1000)

This would output something like that below which includes the ID for each item, and a random number between 1 and 1000.

Select IDs uses the output from Select, but firstly, sorts it by the Order property (our random number), then takes N number of items. In this example, N is the number we entered in our trigger. The expressions used here are:
//From
take(sort(body('Select'), 'Order'), triggerBody()['number'])
//Map
item()?['ID']
//Note that if it was always the same number of random items you wanted, then you could hardcode it as so, where it takes the first 3 items.
take(sort(body('Select'), 'Order'), 3)

If we had entered 3 as our trigger input, then we would end up with a simple array of 3 random IDs.

Lastly, our Filter array will use the output from our Get items and use the output from Select IDs in the filter. Effectively, the filter will be where the array of IDs contains the ID of the list item.

Our Filter array would now contain N number of random items from our SharePoint List. You could then use an Apply to each to iterate over the Filter array and do whatever you need to.
----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.