web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Trying to increment da...
Power Apps
Unanswered

Trying to increment date field in a Gallery using ForAll and Sequence

(0) ShareShare
ReportReport
Posted on by 380

I have a Gallery (Child) that contains a variable number of records linked to a Parent form. The Gallery has a tripdate field where I want to set the first record's date to tomorrow and then increment subsequent records by 1 day - the Gallery is displaying dates from a field trip the user is recording. There are a few other fields in the Gallery; destination, activity, localcontact etc

 

The Gallery's items property is: Filter(TripDetails,tripid=Value(Gallery2.Selected.tripid.Text)) as it is getting the ID from another screen and another Gallery. I have found a post which explained how to use the Sequence function to increment the dates and if I put this on theGallery's items property: ForAll(Sequence(15), {date: DateAdd(Today(), Value, Days)}) and then this on the TextInput for the tripdate: Text(ThisItem.date, ShortDate, "en-GB") it works and the dates are displayed correctly but of course I lose the Filter and the subsequent data.   What I need to do is combine the Filter statement with the ForAll so I get all the fields in the Gallery plus the incrementing dates.

 

I hope I have explained that well enough....

 

Can anyone please assist?

Categories:
I have the same question (0)
  • v-jefferni Profile Picture
    on at
    Re: Trying to increment date field in a Gallery using ForAll and Sequence

    Hi @bobgodin ,

     

    Am not sure if I understand correctly. The logic I assume is, for all the items of the TropDetails list that tripid equal to Gallery2 selected tripid, in the child Gallery make the date column from tomorrow and on. So the child Gallery Items:

     

    ForAll(
     CountRows(Filter(TripDetails,tripid=Value(Gallery2.Selected.tripid.Text))) As SS,
     AddColumns(
     Filter(TripDetails,tripid=Value(Gallery2.Selected.tripid.Text)),
     "Date",
     DateAdd(Today(), SS.Value, Days)
     )
    )
    

     

     

    Best regards,

  • bobgodin Profile Picture
    380 on at
    Re: Trying to increment date field in a Gallery using ForAll and Sequence

    Hi @v-jefferni thanks a lot for that code but I think we may be missing a bracket or something else...see screenshot attached

    cheers

    Bob

  • v-jefferni Profile Picture
    on at
    Re: Trying to increment date field in a Gallery using ForAll and Sequence

    Hi @bobgodin ,

     

    Not a bracket, but the Sequence function:

    ForAll(
     Sequence(CountRows(Filter(TripDetails,tripid=Value(Gallery2.Selected.tripid.Text)))) As SS,
     AddColumns(
     Filter(TripDetails,tripid=Value(Gallery2.Selected.tripid.Text)),
     "Date",
     DateAdd(Today(), SS.Value, Days)
     )
    )

     

    Best regards,

  • bobgodin Profile Picture
    380 on at
    Re: Trying to increment date field in a Gallery using ForAll and Sequence

    Hi @v-jefferni thanks for that - the items code is now looking good but my gallery's textboxes are not happy now - see attached screenshots. The Default property for these textboxes are ThisItem.destination, ThisItem.activity, ThisItem.accomodation etc - do I need to change these now?  sorry bit of a newbie to Powerapps 🙂

  • v-jefferni Profile Picture
    on at
    Re: Trying to increment date field in a Gallery using ForAll and Sequence

    Hi @bobgodin ,

     

    As the formula I suggested was using the AddColumns function to reinforce the original table of the filter result with a Date column, the result table will share a basically same structure as your original table, which means they will have same columns and an additional "Date" column. You can select the whole formula and there will be a small arrow appear below the formula bar, click the arrow then you will see the result table with all its columns:

    vjefferni_0-1664268025412.png

    Then you could use ThisItem.ColumnName for respective Text Input box.

     

    Best regards,

  • bobgodin Profile Picture
    380 on at
    Re: Trying to increment date field in a Gallery using ForAll and Sequence

    Hi @v-jefferni thank you but I don't understand what I have to do to be able to see the datasource for my Gallery...

  • v-jefferni Profile Picture
    on at
    Re: Trying to increment date field in a Gallery using ForAll and Sequence

    Hi @bobgodin ,

     

    Please check Items property of the Gallery.

     

    Best regards,

  • bobgodin Profile Picture
    380 on at
    Re: Trying to increment date field in a Gallery using ForAll and Sequence

    Hi @v-jefferni sorry to be a pain - I have got this far with selecting Items property - I can see it is ThisItem.Value - see screenshot...and I can see the fieldnames below this but when I choose activity, for example, I get "Expected Text value" and the red underline - I tried adding .Text to the end of it but that didn't work.....I think I am close lol

    thanks

    Bob

  • Verified answer
    v-jefferni Profile Picture
    on at
    Re: Trying to increment date field in a Gallery using ForAll and Sequence

    Hi @bobgodin ,

     

    Sorry for my incorrect method. I made an App to repro the issue and then find a way to achieve your need. Please try and set Items property of the Gallery:

     

    ForAll(
     Sequence(
     CountRows(
     Filter(
     TripDetails,
     tripid=Value(Gallery2.Selected.tripid.Text)
     )
     )
     ) As SS,
     Last(
     FirstN(
     AddColumns(
     Filter(
     TripDetails,
     tripid=Value(Gallery2.Selected.tripid.Text)
     ),
     "Date",
     DateAdd(Today(),SS.Value,Days)
     ),
     SS.Value
     )
     )
    )
    

     

     

    Now, Default of Text Input boxes within the Gallery need only ThisItem.ColumnName.

     

    Best regards, 

  • Verified answer
    bobgodin Profile Picture
    380 on at
    Re: Trying to increment date field in a Gallery using ForAll and Sequence

    thanks @v-jefferni that did the trick - I really appreciate the time and effort you took to respond to my query - thank you again 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 757 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 322 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 209 Super User 2025 Season 2

Last 30 days Overall leaderboard