Showing results for 
Search instead for 
Did you mean: 
Resolver I
Resolver I

Hide icon if is not the last record

Hi all,


In this time I have consumed many hours of video tutorials and user manual, and in this moment I building my second App.


This is my first post and I know that there is many people with more time of development, but I can't find my answer and I don't know how I can do it.


The point is that I have in my gallery, all records and I have added an icon to delete the record, but I only want to have this option only for the last record, and I don't know what condition I need write in "visible".


I tried with: "If(BrowseGallery1.Item.ID = Last('origin');true;false)"




Sorry for my English, I hope that you can understand me... hehehe


Accepted Solutions




                 [@'RECEPCIÓN DE MATERIALES']; 
                     Title; TextSearchBox1.Text
                  ); ID ; Descending



in the Visible property of the icon. This formula will show the last item in your gallery and should take into account the filter.  It is not necessarily the last item that is in your unfiltered list. 

View solution in original post

Super User III
Super User III


Are you trying to show an icon only in the final record of the gallery?


Put this code in the Visible property of the icon.

ThisItem.ID = Last(BrowseGallery1.AllItems).ID


Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

@mdevaneythank you for your fast answer, but doesn't works.


The error now is something like "invalid argument type" (in English)Screenshot_2.png



Hi @Manarjomar 

I found that instead of using Last(Browsegallery.AllItems), use the actual formula for the Items property of the gallery instead.  In my example 

nwind_ordernumber=First(Filter(Sort( Orders, 'Order Number', Descending ),TextInput2.Text in 'Order Number')).'Order Number'



Nice work!


Given that we can now see the OP has a sort control and a search box is there a way to write this which takes into account those elements.?


@DrrickrypIs exacly that I want to do it.


But I don't know how can reply your example in my form because I don't understand the function, but I thought also that I need some come condition over the option "Visible" of the trash icon.


Thank you.

Hi @mdevaney 

I'm guessing it depends on whether @Manarjomar  wants to save the last item in the gallery or the last item in the list.  I'm guessing it's the latter. 


My formula was just an example from a sample database.  You would replace my formula with the Items property of your gallery but sort it by ID, Descending and use First().  I almost never use Last() or Max() in my apps because they are not delegatable and if the list exceeds the PowerApps limit, they will not give the correct value.  First(Sort( Descending  will always work no matter how big the data set is. 

@Drrickryp  @mdevaney 


I have my list sorted by id, so I want the trash icon visible only over the last record on the list.


I don't want have the option to delete older records, only the last one, so if I want delete older, necesary I will need delate from the last one first.


Thank you.


Post the items property of the gallery and I will tell you how to write the Visible property of your icon.

Helpful resources

PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!


Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (66,333)