Showing results for 
Search instead for 
Did you mean: 
Kudo Collector
Kudo Collector

SortByColumn: set default value and have it as "selected" for gallery

Is it possible to have the "selected" item "sticky" when using SortbyColumn? For example, I have itemA selected, then I sort the gallery by id. I am hoping to see itemA is still selected, or, at least the 1st item on the new list is selected. Right now, it seems to select a random value after sorting. Thanks. 


Super User
Super User

Hi @NewBee117 ,

The property to control the "sticky" item is TemplateFill for the gallery.

it is normally set to something like If(ThisItem.IsSelected,<Color>,White) meaning it shows the user the last item they selected when they come back to the gallery, which is often on a different screen.

Without seeing your code, it cannot give you a proper answer, but it should be possible if you can refer the other gallery

Lookup(ThisItem.<Identifier>= . . the other gallery.selected.<same id>

Give it a go - happy to help if you get stuck


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.

Thanks for writing back. There is only one gallery in this exercise. Here are my code. 



And here is how the app works:


Stick should keep ItemA selected (blue) regardless which row it is on. Is it possible?

Super User
Super User

Ok @NewBee117 ,

I will get back to you on this - a fair bit of code to look through

Hi @NewBee117 ,

The reason why you met this problem is that:
Gallery.Selected will change to the first item by default.

So when you change the table's order, the selected item will change together.

However, I've figured out a solution to avoid the order's effect.

I suggest you save the table's data to collection and update the selected item to a certain value. Make the item that has the certain value as "selected item".

I've made a similar test for your reference:

I assume that your original table name is test.

1)save the original table as a collection 

set the screen's OnVisible:


//add a column that save the certain value

2)update the collection, update the selected item with certain value (true)

set the arrow button inside the gallery's OnSelect:


set the gallery's Items:

//replace the field that you want

set the sort button's OnSelect:


3)make the item has certain value as the selected one

For example: 

set the arrow button's Color:



Then the selected item's arrow button will be red,others will be blue. And this will not change with the order's changing.






Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I put in your code, and the visual effect looks like it is sticky to the arrow, however, it is not the true selected item after the sort, the item highlighted in blue (TemplateFill) is. Good try though.


ItemA moved to top row with the red arrow and the AddColumn of "selected", however, the third row is the true "selected" in blue.



Super User
Super User

Hi @NewBee117 ,

I will drop out of this - looks like @v-yutliu-msft has got it completely under control

Helpful resources

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (1,792)