cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JR-BejeweledOne
Super User
Super User

Get the current iteration value of sequence

I am trying to simplify the creation of events that are being used in another Power app.    Some events will span more than one day but need to be created individually for the other app to be able to consume them properly. 

 

Here is my starting point.  It works quite nicely, but I need to increment the date each time.   I was hoping there would be a way to capture the number of the sequence iteration to use as the DateAdd value.   Since the date needs to be incremented by an increasing number of days for each iteration that seems like a logical place to get that number.   I.E., Datepicker value 12/23/2022, 1st iteration: increment by 1 - 12/24/2022, 2nd iteration increment by 2 - 12/25/2022, 3rd iteration increment by 3 - 12/26/2022 and so on.

ForAll(
    Sequence((DateDiff(DatePickerHolidayDate.Value, DatePickerHolidayEndDate.Value) -1)),
            Collect(HolidayCollection, 
            {
            Holiday: ComboBoxHoliday.Selected.Name, 
            DateAdd(HolidayDate: DatePickerHolidayDate.Value, 1) 
                       
              }
            )
)

 

Solutions, ideas or suggestions welcome.

 

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
1 ACCEPTED SOLUTION

Accepted Solutions
Alex_10
Memorable Member
Memorable Member

@JR-BejeweledOne 

 

ForAll(
    Sequence((DateDiff(DatePickerHolidayDate.Value, DatePickerHolidayEndDate.Value) -1)) As ThisSequenceNumber,
    Collect(HolidayCollection, 
        {
        Holiday: ComboBoxHoliday.Selected.Name, 
        HolidayDate: DateAdd(DatePickerHolidayDate.Value, ThisSequenceNumber.Value, Days) 
        }
    )
)

View solution in original post

2 REPLIES 2
Alex_10
Memorable Member
Memorable Member

@JR-BejeweledOne 

 

ForAll(
    Sequence((DateDiff(DatePickerHolidayDate.Value, DatePickerHolidayEndDate.Value) -1)) As ThisSequenceNumber,
    Collect(HolidayCollection, 
        {
        Holiday: ComboBoxHoliday.Selected.Name, 
        HolidayDate: DateAdd(DatePickerHolidayDate.Value, ThisSequenceNumber.Value, Days) 
        }
    )
)
JR-BejeweledOne
Super User
Super User

EXCELLENT!    That works beautifully, thank you.



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,694)