Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
4.8k views
in Power Apps by 30 37 42
I have a gallery and PowerApps form , I need when I click on a button it will display the first item from the gallery in the form then when click again it will display the next item and so on, what the correct formula that I can use to get the current item ?

1 Answer

2 like 0 dislike
by 48 54 93
selected by
 
Best answer
  1. First you have to get the first item of the gallery to start with, you can hold it in a variable in some where in your app , for example in the Onvisible property of your screen

Use this formula where Gallery1 is the name of your gallery that displays the items

Set(CurrentGalleryItem,First(Gallery1.AllItems))
  1. In the Onselect property of next button write this formula that will get the next item in the gallery ,

Use this formula in the Onselect property of your button

Set(CurrentGalleryItem,
If(
    CurrentGalleryItem.ID = Last(Gallery1.AllItems).ID,
    First(Gallery1.AllItems),
    First(Filter(Gallery1.AllItems, ID > CurrentGalleryItem.ID))
))

Finally in the item property of your form write CurrentGalleryItem

For more details Click here for a detailed example that will solve this issue

If you don’t ask, the answer is always NO!
...