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 / Gallery only filtering...
Power Apps
Answered

Gallery only filtering connected gallery first choice, not "ALL"

(0) ShareShare
ReportReport
Posted on by

Hi all,

 

I have an app, with a gallery that works like a registration screen (users can registers for courses, etc).

 

To the left of this on the same screen, I have a second gallery, that filters in "Location".

 

I want my registration gallery to default on loading to show "all" current courses, and only filter when the location gallery is selected.

 

This is the code, I am using. Not sure why it isn't working:

 

Filter(
 Sort(
 SP list,
 ‘Date',
 SortOrder.Ascending
 ),
 (Len(LocationGallery.Selected.Location) = 0 || Location = LocationGallery.Selected.Location),
 ‘Date' >= Today()
)

 

Any help would be appreciated.

 

DW

Categories:
  • WarrenBelz Profile Picture
    156,725 Most Valuable Professional on at

    Hi @DGWolfe ,

    Firstly, a Gallery will possibly have a record selected by Default, so the first bit

    Len(LocationGallery.Selected.Location) = 0

    may never be true - you also have the additional filter

    ‘Date' >= Today()

    so there may not be matching records. Have you checked with a Label on the first part above to see if there is anything in there ?

  • DGWolfe Profile Picture
    on at

    @WarrenBelz thanks,

     

    That is correct. Courses, past today's date are hidden.

     

    With the first label, I do have the following:

     

    Sort(SP List, Location, SortOrder.Ascending)

     

    I assume this is what is hiding the "other" choices, that come after the first one. How would I fix this?

     

    DW

     

  • WarrenBelz Profile Picture
    156,725 Most Valuable Professional on at

    Hi @DGWolfe ,

    Your filter should be

    Sort(
     Filter(
     SP List, 
     ‘Date' >= Today()
     ),
     Location, 
     SortOrder.Ascending
    )

    otherwise you could be selecting by Default a course before today, which will have no matches in the second gallery.

     

    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

  • DGWolfe Profile Picture
    on at

    @WarrenBelz 

     

    Thanks, that did help the order, however, what about the second gallery of locations used to narrow down the search?

     

    DW

  • WarrenBelz Profile Picture
    156,725 Most Valuable Professional on at

    @DGWolfe ,

    Sorry I am unclear what you need here - the first gallery (Location Gallery) shows all records where the date is after today. The second then filters this by the location record chosen in the first. What is it that is not being done ?

  • DGWolfe Profile Picture
    on at

    Sorry @WarrenBelz 

     

    Gallery 1 is the "Registration Gallery" where the user can register for a course. 

     

    To the left there is a second gallery "Location Gallery" that the user can filter courses by location. 

     

    I updated the formula based on your edits, but those changes don't factor in the second gallery filter.

     

    Does that make sense?

     

    DW

  • WarrenBelz Profile Picture
    156,725 Most Valuable Professional on at

    @DGWolfe ,

    OK to rewind  bit so I am completely clear - your first Gallery LocationGallery has the Items

    Sort(
     Filter(
     SP List, 
     ‘Date' >= Today()
     ),
     Location, 
     SortOrder.Ascending
    )

     You then have a second Gallery with courses with this as the Items

    Filter(
     Sort(
     SP list,
     'Date',
     SortOrder.Ascending
     ),
     (Len(LocationGallery.Selected.Location) = 0 || Location = LocationGallery.Selected.Location),
     'Date' >= Today()
    )

    and want all the records to be displayed if nothing is selected int he gallery. The fundamental issue could be that the Gallery is selecting the first item by default, so you will never have "nothing" selected. One alternative is to set a Variable at OnSelect of the Gallery.

    UpdateContext({varSelected: true})

    You need to initiate/reset at at screen OnVisible

    UpdateContext({varSelected: false})

     then your Filter

    Filter(
     Sort(
     SP list,
     'Date',
     SortOrder.Ascending
     ),
     (!varSelected || Location = LocationGallery.Selected.Location),
     'Date' >= Today()
    )

     

    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

  • DGWolfe Profile Picture
    on at

    @WarrenBelz Almost!

     

    Gallery1 = Registration gallery. That has: 

     

    Sort(
     Filter(
     SP List, 
     ‘Date' >= Today()
     ),
     Location, 
     SortOrder.Ascending
    )

     

    Gallery 2 = Location gallery. That has: 

     

    Sort(SP List,Location,Ascending)

     

     

    So I was trying to "hide" any of the courses in Gallery1 past today's date, as well as filter based on a choice from Gallery2 Location choice.

     

    But I can try the variable if that will sort it!

     

  • WarrenBelz Profile Picture
    156,725 Most Valuable Professional on at

    @DGWolfe ,

    The result of first one is essentially what I posted (apart form the name). You need the date filter in both galleries as you are querying the data source directly. Is what I posted before for the second gallery what you are trying to do ?

  • Verified answer
    DGWolfe Profile Picture
    on at

    @WarrenBelz 

     

    I ditched the location gallery. It looked good but it was just too much of a hassle. I replaced it with radio buttons, and used the following formula and its firing perfect. 

    Filter(
     Sort(
     'SP List',
     'Date',
     SortOrder.Ascending
     ),
     ('Date' >= Today()),
     (IsBlank(RadioFilterLocations.Selected.Value) || Location = RadioFilterLocations.Selected.Value)
    )

     

    Sorry to wast your time.

     

    DW

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 360 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 325

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard