web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to check for First...
Power Apps
Unanswered

How to check for First or Last items of a Gallery

(2) ShareShare
ReportReport
Posted on by

Hi all,

 

Currently building an app where users can request and approve company travel items.

 

I've built the UI of the "overview" screen as a timeline of travel events (flights, etc). Wondering whether anyone out there might know how to detect whether a given item is the First or Last one in a gallery? Would be useful in showing or hiding aspects of the UI to dictate whether the timeline ends or starts from a particular item.

Cheers

Categories:
I have the same question (0)
  • Verified answer
    Meneghino Profile Picture
    6,949 on at

    Hi @Anonymous

     

    You can use the First and Last functions.  If outside the gallery then you can use the AllItems property of the gallery.

    For example:  If(Gallery1.Selected = First(Gallery1.AllItems), XXX, YYY)

     

    If inside the gallery (i.e. for a control in the gallery template) then I think that you cannot use AllItems, so just use First or Last with the same expression as the Items property of your gallery.

     

    Please provide specific needs (incl. Items property) if the above is not clear enough.

  • Community Power Platform Member Profile Picture
    on at

    Worked brilliantly. Thanks @Meneghino ! 🙂

  • Community Power Platform Member Profile Picture
    on at

    I am trying to apply this idea inside a gallery, on the visible property of an icon. I can't seem to get the syntax right, I'm getting "invalid argument type." Inside the gallery it would be ThisItem=Last(whatever)?


    If(ThisItem=Last(Filter(Datasource,Field=value,Field2=Value2)),true,false)

     

    I'm pretty sure "ThisItem" is the single record within the gallery - if I start typing

    If(ThisItem.

    I see the fields of the table in question in the auto fill area

  • Gyllentid Profile Picture
    894 on at

    @Anonymous hi were you able to find a solution?

  • Kanika_arora Profile Picture
    19 on at

    Hi @Meneghino 

    I tried your suggestion. But getting an error which says can't compare record=record type.

    My requirement is to enable a control in just first row of gallery & disable for rest of the rows.

    So i am using If(ThisItem=First(myCollection),DisplayMode.Edit,DisplayMode.View) on display mode property of that particular control inside gallery.

    Any more suggestions will help.

    Thanks.

  • mychau Profile Picture
    56 on at

    try this

     

    If(ThisItem.ID=First(myCollection).ID,DisplayMode.Edit,DisplayMode.View)

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard