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 / Rearranging the order ...
Power Apps
Answered

Rearranging the order of gallery items so that specific value appears first

(0) ShareShare
ReportReport
Posted on by 578

I have a gallery that shows Counties for each State. The State is selected using a Radio Button, and it filters the counties for the selected State. This part works perfectly. The issue is that the data is in SharePoint, and the counties are ordered in alphabetical order, which is fine, except that there is a "All Counties" value that's always at the end. I don't want the user to scroll all the way down to be able to select the "All Counties" option. Instead, I would like to move this specific option to the very top. The counties are shown in a gallery with Wrap Count = 3.

Screenshot 2023-09-15 123644.png

Radio Button Data

Items = GroupBy(
 Filter(
 State_County,
 RO = myRO
 ),
 "State",
 "GroupedState"
)

 

Gallery Data

//
Items = Filter(
 State_County,
 State = Radio2.Selected.State
)
//--------
Checkbox.Text = ThisItem.County_Name

 

Thanks in advanced for any help.

Categories:
  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @emfuentes27 - have you tried using Sort on that specific value?

     

     

    Sort(
     Filter(
     State_County,
     State = Radio2.Selected.State
     ),
     State = "All Counties",
     SortOrder.Descending
    )

     

     

    ------------------------------------------------------------------------------------------------------------------------------

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

    Imran-Ami Khan

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

    Hi @emfuentes27 ,

    Try this in the Items of the Radio control

    Ungroup(
     Table(
     {
     Data: 
     Table(
     {Value: "All Countries"}
     )
     },
     {
     Data:
     GroupBy(
     Filter(
     State_County,
     RO = myRO
     ),
     "State",
     "GroupedState"
     )
     },
     ),
     "Data"
    )

     

    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

     

  • emfuentes27 Profile Picture
    578 on at

    @WarrenBelz . Thanks for the reply, I really appreciate it, but it doesn't work. I get a few errors, including:

    1. Invalid number of arguments, received 1, expected 2.

    2. Function Table has some invalid arguments. 

    3. Cannot use non-record value in this context. 

  • emfuentes27 Profile Picture
    578 on at

    @Amik . Thanks for the reply, but the change you proposed doesn't do anything, "All Counties" still at the end.

  • Verified answer
    emfuentes27 Profile Picture
    578 on at

    I was able to figure it out using @RandyHayes videos. and adapting it to my needs. It is not pretty, but good enough for now:

    Radio:

    Items: 
    GroupBy(
     Counties_States,"State",
     "GroupedState"
    )
    
    OnSelect: 
    ClearCollect(
     Cnty_Col,
     {County_Name: "All Counties"},
     Filter(
     Counties_States,
     State = StatesRadio.Selected.State && County_Name <> "All Counties"
     )
    )

     

    Gallery:

    Items: Cnty_Col

    The biggest difference regarding the data is that I had to load all State/County data when App stars, because I was getting some Delegation warnings, and there 3000+ counties in the US, so I was hitting some limits. So I created the 

    Counties_States collection with all the data.

    I hope this help somebody.

     

    Thanks for the help.

     

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 396 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 323

#3
WarrenBelz Profile Picture

WarrenBelz 193 Most Valuable Professional

Last 30 days Overall leaderboard