cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Manarjomar Helper II
Helper II

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)"

 

Thanks.

 

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

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Hide icon if is not the last record

Try

 

 

ID=First(
      Sort(
         Filter(
                 [@'RECEPCIÓN DE MATERIALES']; 
                  StartsWith(
                     Title; TextSearchBox1.Text
                            )
                  ); ID ; Descending
                 )
             ).ID

 

 

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

12 REPLIES 12
Super User
Super User

Re: Hide icon if is not the last record

@Manarjomar 

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."

Manarjomar Helper II
Helper II

Re: Hide icon if is not the last record

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

 

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

 

Regards,

Super User
Super User

Re: Hide icon if is not the last record

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'

Capture.PNG 

Super User
Super User

Re: Hide icon if is not the last record

@Drrickryp 

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.?

 

Manarjomar Helper II
Helper II

Re: Hide icon if is not the last record

@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.

Super User
Super User

Re: Hide icon if is not the last record

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. 

Super User
Super User

Re: Hide icon if is not the last record

@Manarjomar 

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. 

Manarjomar Helper II
Helper II

Re: Hide icon if is not the last record

@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.

Super User
Super User

Re: Hide icon if is not the last record

@Manarjomar 

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

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (8,021)