I want to fill a Datatable in a loop by pressing a Button.
For example by pressing the Button the existing Datatable will be written as like :
Does somebody has a Idea how to do it ?
If you're using model-driven apps, then this is out of the box (OOB). All you need to do is define your table and form and use the OOB "New" button as the button to create new rows.
To set up auto number (SerialNr. column): https://docs.microsoft.com/powerapps/maker/data-platform/autonumber-fields#create-an-autonumber-colu...
Hope this helps!
Using a combination of ForAll, Sequence, and Patch to a collection that the table is connected to might do it. You can define how many rows you want in Sequence then in the Patch function SerialNr would be whatever Sequence you're on and PersNr. would be what you have there already.
Code for the 'Generate' button: