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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Given a selected recor...
Power Apps
Answered

Given a selected record from a gallery, can I do a next or previous?

(0) ShareShare
ReportReport
Posted on by 894

In one screen, I have a gallery with datasource PhotoImages.

When an image is selected from the gallery, it navigates to the next screen, passing the selected record as SelectedImage.

 

Navigate(Screen4,None,{SelectedImage: Gallery2.Selected})

 

On the next screen, I want to give the user the opportunity to use Next & Previous, rather than having to keep going back & forward.

Can I reset SelectedImage to the Next or Previous item in my datasource?

If so, how?

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Does your data source have incrementing numeric IDs? You could use that to get your gallery data. as in:

    Filter(CustomGallerySample,ID = yourSelectedID)

    Then you can have a "Previous" and "Next" button that do this:

    Previous:
    Set(yourSelectedID,yourSelectedID - 1)
    
    Next:
    Set(yourSelectedID,yourSelectedID + 1)
  • stapes Profile Picture
    894 on at

    Thanks @Anonymous

    Unfortunately, the next sequential ID may not be linked to the same parent.

    I was hoping I could use Next or Previous within the Datasource already referenced. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    You should still be able to use that sequence ID as long as your data is relational. Can you give a brief rundown of your data structure? For example, if your sequence ID is in another table, but your data is related through a different ID column, you can use Lookup() to find it and increment that.

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @stapes ,

    Could you please share a bit more about the data structure of your PhotoImages?

    Is there a "Row Index" column existed in your PhotoImages data source?

     

    Based on the needs that you mentioned, I afraid that there is no direct way to achieve your needs in PowerApps currently. As an available solution, you could consider add a "Row Index" column in your PhotoImages data source as index number, e.g. 1, 2, 3, 4, ...

     

    If you want to add a "Row Index" column in your PhotoImages data source, please consider take a try with the following workaround:

    Set the OnStart property of App to following:

    Clear(PhotoImagesCollection);
    ForAll(
     PhotoImages,
     Collect(
     PhotoImagesCollection,
     {
     RowIndex: CountRows(PhotoImagesCollection) + 1,
     Column1: PhotoImages[@Column1],
     Column2: PhotoImages[@Column2],
     Column3: PhotoImages[@Column3],
     ...
     }
     )
    )

    Then set the Items property of the image Gallery  (Gallery2) to following:

    PhotoImagesCollection

     

    Then modify your Navigation formula as below:

    Navigate(Screen4, None);Set(SelectedRowIndex, Gallery2.Selected.RowIndex)

    Within your Next screen, you could reference the selected image data from your Gallery2 using the following formula:

    LookUp(PhotoImagesCollection, RowIndex = SelectedRowIndex).ImageDataColumn

     

    Set the OnSelect property of the "Next" button to following:

    Set(SelectedRowIndex, SelectedRowIndex + 1)

    Set the DisplayMode property of the "Next" button to following:

    If(
     SelectedRowIndex + 1 > Max(PhotoImagesCollection, RowIndex),
     DisplayMode.Disabled,
     DisplayMode.Edit
    )

     

    Set the OnSelect property of the "Previous" button to following:

    Set(SelectedRowIndex, SelectedRowIndex - 1)

    Set the DisplayMode property of the "Previous" button to following:

    If(
     SelectedRowIndex - 1 < Min(PhotoImagesCollection, RowIndex),
     DisplayMode.Disabled,
     DisplayMode.Edit
    )

     

    Please consider take a try with above solution, then check if the issue is solved.

     

    Best regards,

  • stapes Profile Picture
    894 on at

    Brilliant solution @v-xida-msft - the only think I had to change was

     

    UpdateContext({SelectedRowIndex: SelectedRowIndex + 1})

     

    instead of

     

    Set(SelectedRowIndex, SelectedRowIndex + 1)

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard