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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Gallery question (look...
Power Apps
Unanswered

Gallery question (lookup user, 'local' vs 'remote')

(0) ShareShare
ReportReport
Posted on by 241

I have the following scenario:

  • In my app I want to display a gallery with a selection of entities
  • The gallery must display (among other fields) the name of the user who created the item
  • The last item in the gallery must be in view

 

For sake of illustration, let's say I want to display 'Accounts'. So, I add a Gallery to a screen and set the Items to "SortByColumns( Accounts, "createdon" )", and I add a label that displays ""Account name: "&ThisItem.'Account Name'&" -- Created by:"&ThisItem.'Created By'.'Full Name'". This works as expected. Now I want to set the last item into view, so I try setting the Default item to 'Last(Gallery1.AllItems)'. But, this doesn't work.

Next attempt: I initialize a local variable 'loadedAccounts' as such: 'UpdateContext({ accounts: SortByColumns( Accounts, "createdon" ) })'. Then I set the gallery source to 'loadedAccounts', and the Default to 'Last(loadedAccounts)' (*: note: it might take an intermediary variable that you can Blank() first in order for this to work in all cases). In this case, after loading the accounts, the 'proper' element is scrolled into view, but the user name stays empty!

 

Illustrated side by side:

gallery.png

 

My first question: in the first scenario, is there any way to set the 'Default' item in such a way that it works? 

My second question: in the second scenario, why does the 'default' way of retrieving the user name not work, and how can I work around it?

Categories:
I have the same question (0)
  • v-monli-msft Profile Picture
    Microsoft Employee on at

    Hi @MrNappa ,

     

    In the first scenario, the formula should be:

    Last(SortByColumns( Accounts, "createdon" ,Descending))

     

    Regards,

    Mona

  • MrNappa Profile Picture
    241 on at

    @v-monli-msft wrote:

    Hi @MrNappa ,

     

    In the first scenario, the formula should be:

     

    Last(SortByColumns( Accounts, "createdon" ,Descending))

     

     

    Regards,

    Mona


    Thanks for the suggestion, Mona.

     

    I tried this, but it doesn't work. Also, won't that do an additional load from the datasource? Which seems redundant, seeing the data is already present in the gallery.

  • MrNappa Profile Picture
    241 on at

    So after more fiddling and research, I came to this conclusion:

     

    • Setting the gallery 'Items' to a CDS data source directly works. 
      Using some lookup value in the gallery template resolves as expected. E.g., "ThisItem.'Created By'.'Full Name'"
    • There is some magic involved though -- if you look at the Gallery.AllItems in the inspector, you will notice that the 'created by' column is empty.
    • If retrieving the data first into a collection ( ClearCollect ) or variable ( UpdateContext/Set ,as shown in example ), the inspector also shows that the 'created by' column is empty. In addition, the magic that happens in the other case is not present here
    • This is probably a bug, as referenced here and here?

    In the end, I was forced to retrieve the data and use 'AddColumns' myself in order to fill the data properly (as referenced in the other thread). With the obvious drawback that modifying a record from that gallery becomes more complicated, too, again.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 510

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Vish WR Profile Picture

Vish WR 281

Last 30 days Overall leaderboard