Solved! Go to Solution.
The works, however it's the order that matters:
ClearCollect(
GalleryCollection,
FirstN(
Shuffle(
Filter(
'SharePoint Online List',
IsBlank(Selector1.Selected.Result) Or SPOListColumnA = Selector1.SelectedText.Value,
IsBlank(ComboBox1.Selected.Result) Or SPOListColumnB = ComboBox1.Selected.Result,
IsBlank(ComboBox2.Selected.Result) Or SPOListColumnC = ComboBox2.Selected.Result,
),
3
)
)
)
You can set the Items property of the gallery to the following expression:
FirstN(Shuffle(YourSharePointList), 3)
That will first Shuffle the items of the list (notice that it doesn't modify the list itself, the shuffle is done with the items in memory), then takes 3 of those elements.
Hope this helps!
Hi, that seems to work, however sometimes it shows one result, sometimes no results, sometimes two, sometimes three. Is there a way to always return random three results if available?
Hi @cbernier35 ,
I'm afraid there's no function about returning a specific number of random records in PowerApps.
As an alternative, since Shuffle() function will return at least one record every time, I suggest you collect its data for three times.
Then the result table's record number must be larger than three.
Try this:
1)set the screen's OnVisible:
ClearCollect(test,Shuffle(datasource));Collect(test,Shuffle(datasource));Collect(test,Shuffle(datasource))
2)set the gallery's Items:
FirstN(test,3)
Best regards,
The works, however it's the order that matters:
ClearCollect(
GalleryCollection,
FirstN(
Shuffle(
Filter(
'SharePoint Online List',
IsBlank(Selector1.Selected.Result) Or SPOListColumnA = Selector1.SelectedText.Value,
IsBlank(ComboBox1.Selected.Result) Or SPOListColumnB = ComboBox1.Selected.Result,
IsBlank(ComboBox2.Selected.Result) Or SPOListColumnC = ComboBox2.Selected.Result,
),
3
)
)
)
User | Count |
---|---|
251 | |
102 | |
94 | |
47 | |
37 |