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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / how to auto select the...
Power Apps
Unanswered

how to auto select the first record of the filtered gallery

(0) ShareShare
ReportReport
Posted on by 2

I am working on team power app.

 

I have gallery whose record/Item it getting filtered based on another gallery selected.

I wanted the the first item the gallery to be select automatically, so I put the below code.

First(Self.AllItems)
 
But the disadvantage is that when I select the second or other record by mouse, it auto get back to first gallery.
Please advise, it there another way to get the record selected after filter, and also allow to select other records.
 
 
 

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    Hi @MIA27 ,

    Make the Default of the gallery the same code as the Items except use LookUp instead of Filter.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • DJ_Jamba Profile Picture
    2,837 Super User 2025 Season 2 on at

    Hi @MIA27 

    Make sure the Default property of the gallery is blank.

    Then in the OnVisible property of the screen add:

    Reset(galleryName)

     

  • MIA27 Profile Picture
    2 on at

    I have not understood your tips of "except use LookUp instead of Filter."

     

    I used the same code but getting the error 

    MIA27_0-1711863172000.png

     

    Filter(TablePartsReturnB,FormNo=Value(TextBox2.Value))

    Could you please guide, how to change above code to lookup method.

     

     

     

  • MIA27 Profile Picture
    2 on at

    It will not work by visible of the screen, as data filter is changing based on the text box on the screen,

    User changes and the gallery filter accordingly.

     

    Please note my first post, the issue which  I have done, it does but on mouse selection on the second onward records, it goes back to first.

    It is important as based on the selection of this gallery item another gallery is depended.

     

    Regards

     

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @MIA27 ,

    What is the Items of your Gallery (in Text please)

  • MIA27 Profile Picture
    2 on at

    Dear Mr. Warren,

    Kindly note under the image i put the text also in my last post.

     

    Code in Item property of my gallery is 

    Filter(TablePartsReturnB,FormNo=Value(TextBox2.Value))

     

    Please advise

  • Verified answer
    WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @MIA27 ,

    I was on phone before - missed that, however I was expecting a static filter of some sort. For the Default, you need

    First(TablePartsReturnB)

    however if you are not showing any records to begin with

    LookUp(
     TablePartsReturnB,
     FormNo = Value(TextBox2.Value)
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • MIA27 Profile Picture
    2 on at

    Dear Mr. Warren,

    I applied the lookup method and it worked, once I change the filter criteria, the gallery in subject remains on the first record selected. That exactly was the requirement.

     

    Just for my learning purpose and to apply at few more screen for the similar situation.

    It is possible to for the below code which I have applied on Items property, can have it default property so that the gallery based on it stay on the first records as we solved:

     

    On Item Property - Code is :

    SortByColumns(
    Filter(SupportSvcLocalDV,SerialNo = SearchResultGallery_2.Selected.Serial),"cr333_svcdate",SortOrder.Descending)
     
    Thefore, I tried the below code:
    LookUp(
    SupportSvcLocalDV,
    SerialNo = Value(SearchResultGallery_2.Selected.Serial)
    )
     
    But it gives below error:
    MIA27_0-1711882406992.png
     
    Kindly guide
     
  • Verified answer
    WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @MIA27 ,

    Two things here - you have used Value() in the LookUp and not in the Filter and you also need to use SortByColumns in the LookUp, except it needs to be inside, not outside.

  • MIA27 Profile Picture
    2 on at

    Sorry,

    I tried the below, no error is coming, but sorting is not getting implemented, If I putting with lookup in Default:

     

    As you advised, I changed as below, to shift the sorting inside the lookup

     

    On Item property code is :

    Filter(SupportSvcLocalDV,SerialNo = SearchResultGallery_2.Selected.Serial)
     
    On Default property of the gallery:
    LookUp(
    SortByColumns(SupportSvcLocalDV,"cr333_svcdate",SortOrder.Descending),
    SerialNo = SearchResultGallery_2.Selected.Serial)
     
     
    Please guide further, for its perfection.
    Regards
     

     

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard