Showing results for 
Search instead for 
Did you mean: 
Level: Powered On

How can I clear Gallery.Selected/ThisItem

I have a Gallery which's Selected-property I would like to define by my code (a context variable or something like that). But on Gallery.Selected you cannot use = or any other operator. What would a solution be?


Thanks in advance.

Level 10

Re: How can I clear Gallery.Selected/ThisItem



Can you provide details or examples so that this can be easily figured out to support you as much as possible?


Level: Powered On

Re: How can I clear Gallery.Selected/ThisItem

Let's say you have a Gallery like in the Service Desk Example (Currently I cannot make an app from template, might be a temporary issue, hence the question here and not testing myself in existing code 😉 ).

I have filter buttons which create filters to the data source. If e.g. switch the filter I want that the Gallery selects the first element. On click of these elements I set the a context variable (currec: ThisItem). It works to show the data in a form or so with this context variable but e.g. Gallery.Selected = currec does not work, because there doesn't seem to be an overload for the operator= for this property. So my question would be how I can clear or set the Gallery.Selected so the Gallery "jumps" to what ever element I specified.

Level 10

Re: How can I clear Gallery.Selected/ThisItem

Hi, if I understand your needs correctly then in theory the Default property of the gallery is what you would need to use.



1) Setting this property to either First(MySource) or First(Gallery1.AllItems) has not actually changed the behaviour of my test gallery

2) There seems to be no corresponding Reset property such as exists for text input controls that also have the Default property


It would be great if someone who knows could clarify how to use the Default property of galleries.


On a different tack, are you really sure you need to have one of the items of the gallery selected by default?  What is the scenario whereby you need to "jump" to another element without it actually being selected in the gallery by the user?

Level 10

Re: How can I clear Gallery.Selected/ThisItem



Sorry for my poor understanding of your explanation. If you have data and linked here, maybe I can understand better. :).


Anyway, I try to figure out your question.


In sample or create apps from PowerApps, Gallery is always linked to datasource (say TableX). Then, in your filtering, you always see that they set Items = Filter(TableX, TextInput1.Text in ColumnTitle).

This is more on PULLING method.


I would suggest that using PUSHING method.

Set the Items of the Gallery to any name, say : SourceX

Then add any Button, or Image, Box, TextInput and set

OnSelect / OnChange =  ClearCollect(SourceX, Filter(TableX, TextInput1.Text in ColumnTitle1 || TextInput1.Text in ColumnTitle2 ||.....)) or if using

Search: Set as : Search(TableX, TextInput1.Text, "ColumnTitle1", "ColumnTitle2", "ColumnTitle3",..)


I wish I am replying to the right things.

If not, please link the app / excel and I will try to rewrite.


Hope this helps.

Level 10

Re: How can I clear Gallery.Selected/ThisItem



If I did not misunderstand you, then the following may be able to explain better:

(I am using Project Siena for quick demo and it is the same for PowerApps).



Level 10

Re: How can I clear Gallery.Selected/ThisItem

I had a similar need for my app. In the end, I decided not to bind my elements to Gallery.Selected despite how convenient it was.

I used a context variable instead, since it is currently more flexible: 

  1. Add a Button within the gallery. Stretch it across the template. Remove its text.
  2. Set the Button's Fill to: 
    RGBA(0, 0, 0, 0)
  3. Set Button.OnSelect to:
    UpdateContext({variable: put Gallery.Selected.ThisItem, true/false, or whatever value/text you need here})
  4. Apply the variable to your needs. You can use variable just like ThisItem.
  5. I don't have a fix for clearing the Gallery.Selected. Instead, I made the Visible property of my other item to be FALSE whenever my variable was blank or empty:
    Set another Button to clear the variable:
    UpdateContext({variable: ""})
    Or if the variable was a table:
    UpdateContext({variable: Defaults(the table referenced in the Gallery)})
    Then set the Visible property of your other items affected by Gallery.Selected to:
    !IsBlank(variable)     <----- if your variable is some kind of text/value
    !IsEmpty(variable)     <----- if your variable is a table
Microsoft Employee
Power Apps Staff murali
Power Apps Staff

Re: How can I clear Gallery.Selected/ThisItem

Can you try setting Gallery.Default = currec? That should work.

Level: Powered On

Re: How can I clear Gallery.Selected/ThisItem

Sorry guys, I am currently not working on this project, but I will come back to you when this topic is an issue again. Thanks though for your proposals, I will test them soon

Helpful resources


Power Apps Super User Class of 2020

Check it out!


Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020


Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,223)