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 / Filtering by locations...
Power Apps
Answered

Filtering by locations - Gallery

(0) ShareShare
ReportReport
Posted on by 1,625

All,

Curious if this is easy to do?

I have a 10+ locations, when a user clicks the location button they navigate to a screen with a gallery, where only those location items are visible - rather than all the items from the SPO list.

 

I thought variables, each buttons OnSelect set to a vLocation1, vLocation2 etc. variable, this is my code and some from previous apps but not entirely sure if this the best way to deal with this,  but more importantly if it is, well I'm stuck.
In SPO I have a location field which is a choice column 

Sort(
 Filter(
 SPOList,
 (
 If(vLocation1 = true, // not sure how to take this stament further?
 ) &&
 
 StartsWith(
 Name.DisplayName,
 tbSearchInput.Text
 )
 ),
 RefNo,
 Descending
)

Thank You

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

    Hi @Lefty ,

    You are close (actually you had two brackets not needed), but you can also shorten it as below

    Sort(
     Filter(
     SPOList,
     vLocation1 &&
     StartsWith(
     Name.DisplayName,
     tbSearchInput.Text
     )
     ),
     RefNo,
     Descending
    )

    I have a section on my site concerning the true/false that may be worth a read for you.

     

    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.

     

     

     

     

  • Lefty Profile Picture
    1,625 on at

    @WarrenBelz 

    As always thanks for your response 

    I'll have a try and a read of your post when I'm in the laptop.

    But i noticed what if I want to have vLocation, vLocation2, vLocation3 etc. and only ever needing to see which ever variable is active. 

    How do I write that part of the code?

  • WarrenBelz Profile Picture
    154,793 Most Valuable Professional on at

    @Lefty ,

    If you want any of the Locations

    Sort(
     Filter(
     SPOList,
     (vLocation1 || vLocation2 || vLocation3) &&
     StartsWith(
     Name.DisplayName,
     tbSearchInput.Text
     )
     ),
     RefNo,
     Descending
    )

     

    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.

  • Lefty Profile Picture
    1,625 on at

    Hi @WarrenBelz 

     

    Just looking at the code in more detail and I haven't tried it as I don't see how me clicking on a button on another page filters  where its setting a variable OnSelect of that button, and navigating to the gallery screen, it will display only those items which contain the values linked to that button?
    The vLocation1, vLocation2 etc. I was looking to create as variables on the basis when the user navigated to the gallery screen they would only see the active variables items in my gallery, but I cannot see in the code where the variable is linked to the location fields values?
    Have I completely missed a point here, i thought I needed another filter in the middle, if you can have 2 filters?

  • WarrenBelz Profile Picture
    154,793 Most Valuable Professional on at

    @Lefty ,

    Sorry, I am a bit lost here. This is a logic more than a coding exercise. The code I sent will show whichever (it will show more than one if they are true) location Variable is set. The thing you have to remember to do is to "unset" (set to false) the two you do not want to see when you set the other one to true.

     

    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.

  • Lefty Profile Picture
    1,625 on at

    @WarrenBelz 

     

    I appreciate all your help. I will try explain better.
    What I need help with is, firstly to see if its possible and if it is:
    when a user is on Screen2 and clicks on Location1 button, They navigate to GalleryScreen displaying only Location1 items, I can put the logic in to make all other variables false, but I'm unsure where/how I am supposed to link vLocation1 to Location1 in my choice column 

    I thought something like this would work but clearly not:

     

    Sort(
     Filter(
     SPOList,
     (
     vLocation1 = true, Location.Value = "Location1" || vLocation2= true, Location.Value = "Location2",
     &&
     
     StartsWith(
     Name.DisplayName,
     tbSearchInput.Text
     )
     ),
     RefNo,
     Descending
    )
  • Verified answer
    Lefty Profile Picture
    1,625 on at

    Hi @WarrenBelz 
    I've got this working (he says) 

    On each of the buttons I have the following with the Location1 being the difference on each button:

     

     

     

    Set(vLocation, "Location1"); Navigate(ViewScreen)

     

     

     Then on the gallery screen I have:

     

     

     

    Sort(
     If(IsBlank(vLocation)||vLocation="All",SPOList,Filter(SPOList,Location.Value=vLocation)), 
     RefNo,
     Descending
    )

     

     

     

    I think this works.... time will tell

  • WarrenBelz Profile Picture
    154,793 Most Valuable Professional on at

    @Lefty ,

    Pretty close to my first post working off the limited information I had.

     

    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.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 519 Most Valuable Professional

#2
11manish Profile Picture

11manish 489

#3
Haque Profile Picture

Haque 327

Last 30 days Overall leaderboard