Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

powerapps forall

I am using the SharePoint List as a database with a title DateStart. When a user enter a number to represent a number of days (eg: 3), I would like to create 3 date records with a starting date based on today. (DateStart (dd/mm/yyyy) should be 6/12/2020, 7/12/2020, 8/2/2020. I have try to the ForAll function and Patch function, and managed to create the datestart 3x times but with the same date 6/12/2020. How do you use the increment in the ForAll loop so the date increase? 


Accepted Solutions


No worries, happy to help.


Yes, this is doable, it just becomes a little math problem - with some added on screen logic. The logic I would use is make users pick a certain day of the week to make the math easier eg Monday (you can pick Sunday or another day if you like but I'll work on Monday here).


So, user selects a Monday and the record inside your Patch gets updated to:

Patch(ABC, Defaults(ABC),
// add a Monday record
{RecurrenceDateDaily: DateAdd(DateValue3.SelectedDate, ((Value-1) * 7), Days)},

// add a Thursday record
{RecurrenceDateDaily: DateAdd(DateValue3.SelectedDate, ((Value-1)*7) + 3, Days)}


You can use the same ForAll() structure and same counter you setup before.


To check if a user has picked a Monday, put this is a label somewhere (oh, and also Disable/Enable your Save button depending on if a Monday has been chosen or not):

    "Please chosen a Monday date. You cannot Save your data",
    "Your data is ready to Save")

Note: Weekday() returns a number from 1-7, Sunday=1 ,  Monday=2 ...




View solution in original post

Super User
Super User

Hi @SimonDu88 ,

Try DateAdd - if you want assistance with the code, let me know.


Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

thanks for your reply.

I would like to add a counter in the ForAll loop so the date will be different. using DateAdd() function will only created the same date being created (eg:.  the number of days = 3, the date should be  "6/12/2020, 7/12/2020, 8/2/2020" but instead the date  6/12/2020 has been repeatedly created 3x times.

could you please advise on how to create incremental inside using the forall function?

thanks in advance



Hi @SimonDu88 ,

I can think of a "messy" way immediately - this is below. I will give it some more thought if this does not suit you.

If you are not dealing with a lot of numbers (and you could restrict a user by testing the value and giving a warning and resetting the field if above this),  you could consider some cascading logic

Do the first one for one day later then
   Value([user input field]) > 1,
   DateAdd + 2
   Value([user input field]) > 2,
   DateAdd + 3
   Value([user input field]) > 3,
   DateAdd + 4
and so onwards


Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.


Super User
Super User


Adding to what @WarrenBelz has offered, I found inspiration from this older post


I'm actually struggling with something similar, and I'm still stuck, but this code will do what you want, I think?

            DateDiff(Today(), DateAdd(Today(),Value(TextInput1.Text),Days), Days)),
            "Day " & (Value + 1),
            DateAdd(Today(), Value, Days)

I have this code in an OnSelect of a button and a TextInput called TextInput1.

Note: this is limited to Max 30 days but you can just keep adding values between the [ ... ] to meet your Max needs.


In Play mode, enter a value in the text input field, say 5, and this is the collection created:


You would just need to work out how to get your number of days from your SP list into this code, shouldn't be hard though. 


I'll keep plugging away on my problem ...


Hope this helps


Hi @WarrenBelz ,

Please see my code as below,  I managed to patch the recurrence date "RecurrenceDateDaily" based on the number of days "DataCardValue1.Text".

(For example: if DataCardValue1.Text = 3, then my RecurrenceDateDaily will be 10/2/2020, 11/2/2020, 12/2/202, based on the date "DateValue3.SelectedDate" = today's date. However, I got 10/2/2020,10/2/2020,10/2/2020. As you can see the date does not increment.) - Please advice, thanks. Today is the deadline for my project.

please see attached Pic.

"ABC" is my SP online List






FirstN(Collect_NbrRecurrence, Value(DataCardValue1.Text)),

Defaults(ABC), {RecurrenceDateDaily: DateValue3.SelectedDate} )

Frequent Visitor

Hi @Eelman ,


Thanks very much for your input.

this is what I want but would like to patch it to the SP online list instead.

Could you please provide further advice on how to patch it back to SP online list?

Please see my most recent email to WarrenBelz, explaining my code.

your help will be much appreciated. 

Hi @SimonDu88 ,

Due to timezone issues, I will be offline for a while - I will leave you in the very capable hands of @Eelman .

Happy to have another look at it later if you have not solved it between you.




You are basically there already, just a minor change to your code as per below.


Change this code snippet:


{RecurrenceDateDaily: DateValue3.SelectedDate}


to this:


{RecurrenceDateDaily: DateAdd(DateValue3.SelectedDate, Value, Days)}



This should work?


EDIT: actually, that will start you a day ahead of what you want ... change "Value" to "Value-1"

Frequent Visitor

Hi @Eelman  (Genius),


May I allow myself to make a great announcement about you. YOU'RE SUPER GENIUS!


Thank you so much for your quick  response.

if I want to do the same thing for the weekly, I would assume i should create another collection for weekly?

The situation is that user would also like to put the number of weeks (eg: 5 weeks, but every Monday and Thursday for 5 weeks). Would the concept be the same? How would you go about doing the date as this is not every day?


thanks in advance.

Helpful resources

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,476)