Hi,
I need that when the user press the button, the app show one aleatory line of the my Excel.
Thank you!
You will need to incorporate the Rand function to do this.
You can use a Formula such as this:
Last(
FirstN(
yourDataSource, RoundDown(Rand() * (CountRows(yourDataSource) +1) + 1, 0)
)
)
I hope this is helpful and gets you to the next step.
Hi @Haufe ,
Do you want to display one Random row of your Excel table within your app when you press the button?
Based on the needs that you mentioned, I think the Shuffle function and First function could achieve your needs. The Shuffle function used to randomly reorder the records of a table.
Please take a try with the following formula within your app:
First(Shuffle('YourExcelTable'))
On your side, please take a try with the following workaround:
Set the OnSelect property of the Button to following:
ClearCollect(RandomRecord, First(Shuffle('YourExcelTable')))
Add a Data table control, set the Items property to following:
RandomRecord
More details about Shuffle function and First function, please check the following article:
Shuffle function, First function
Best regards,
Now there's a function I had forgotten about...Shuffle! Good one.
Hi v-xida-msft,
Thank so much for your answer.
I did everything but didn't work, does not show anything in the data table.
APP
OnStart = Collect(RandomRecord ; First(Shuffle(Table1)))
Data Table
Items = RandomRecord
Button
OnSelect = ClearCollect(RandomRecord; First(Shuffle(Table1)))
Best regards,
Hi @Haufe ,
Could you please share a screenshot about your issue?
I have made a test on my side, and don't have the issue that you mentioned. The screenshot as below:
Please check if you have enabled proper fields to display within the right Data Fields panel (as the first screenshot mentioned).
More details about enabling display fields in Data Table control within Fields panel, please check the following GIF screenshot:
If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved.
Best regards,
Hi @Haufe ,
I could not reproduce your issue on my side. Please check if the Collection1 that you initialized in your app is populated with proper values after you click the Button.
Please go to File-> Collections, then check if the Collection1 variable that you initialized within your app is populated with proper values. If not, please consider re-create a new connection to your Table data source, then try your formula again, check if the issue is solved.
In addition, please consider take a try to add a Label control in your app, set the Text property to following:
Collection1.RE
check if Label could display proper value.
You could also consider use Gallery to display your record instead of using Data Table control. The screenshot as below:
On your side, please set the Items property of the Gallery to following:
Collection1
If the issue still exists, please consider take a try to re-create a new app, try your formula again, check if the issue still exists.
Best regards,
Hi @Haufe can you review the latest reply and update the thread when you have a chance?
Thank you.,
@Anonymous
Hi TopShelf-MSFT,
Unfortunately does not work, i did everything like told me.
I created another app, update my conection with the table, and saw about the collection, but the same thing .
Best regards,
User | Count |
---|---|
224 | |
100 | |
94 | |
57 | |
31 |
User | Count |
---|---|
281 | |
114 | |
110 | |
63 | |
57 |