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 / Dynamically identify n...
Power Apps
Unanswered

Dynamically identify number of item in gallery list, and update Y value of other item based on this.

(0) ShareShare
ReportReport
Posted on by

Hi All,

 

I have a gallery ('MenuListGallery'). I have a search bar ('Search Bar') which filters the items in the gallery.

 

Let's say that the item titles of the list are the following:

 

A

B

C

D

etc.

 

In this case, item "C" is the 3rd item. If item "C" is selected, is there a way to identify the number "3", so that can be used to update a mathematical formula elsewhere?

And also, let's say that based on the search filter, items "A" and "B" temporarily disappear, and item "C" is now in the 1st position. Can the previously mentioned "3" dynamically update to "1", so as to dynamically update that mathematical formula?

 

Thanks in advance.

Categories:
I have the same question (0)
  • VasileR Profile Picture
    298 Super User 2024 Season 1 on at

    Hi @ashleynicholson ,

     

    For your first question, getting the "3":
    easiest way is to add an Index column to your source, and on a selection in the gallery, you now have the index of the selected item:
    eg: MenuListGallery.Selected.Index

     

    On a filtered gallery, you can get the first item with:
    eg: First(MenuListGallery.AllItems).Title

     

    Depending on what you want to achieve, it might worth a look at Flexible Height Gallery.

  • AN-31011359-0 Profile Picture
    on at

    Hi,

     

    Apologies if my question wasn't clear.

     

    The number of items in the gallery will update dynamically based on the search filters that are present. So, an item could be Index #52 with no filters applied, but could move to #25 or #3 or any other position as the case may be. Is it possible to pull that dynamically changing number? Thanks.

  • VasileR Profile Picture
    298 Super User 2024 Season 1 on at

    You could try to build dynamically an indexed collection:

    Clear(IndexCollection);
    ForAll(MenuListGallery.AllItems,Collect(IndexCollection,{Title:Title,Index:Value(Last(IndexCollection).Index)+1}));

     

    Then, you can use it as you want:

    eg: 

    LookUp(IndexCollection, Title = MenuListGallery.Selected.Title).Index -> returns 3 in your first scenario, when C is selected
    if "A" and "B" have been filtered
    First(IndexCollection).Title -> returns "C" 
    First(IndexCollection).Index -> returns 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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 494

#2
WarrenBelz Profile Picture

WarrenBelz 352 Most Valuable Professional

#3
11manish Profile Picture

11manish 323

Last 30 days Overall leaderboard