Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Gallery Selected Item by default

(0) ShareShare
ReportReport
Posted on by 216 Super User 2025 Season 1
It has been a while since I have posted, but this one has me stumped!
Background - I have a project system that tracks contracts associated with the selected project. Each contract is also associated with a type (ie. Labor, Material, Other, etc...).
The type (is a collection - colContractType) that gets built from a SharePoint List. And this I have no issue with. Collection gets built based on Filter() and I am using AddColumn() and ShowColumn() to reduce the number of columns in the collection.
What I am trying to do is this:
When you "Add" a new contract to the list from in colContractType, there is no item selected by default. I am using {} in the Default field of the Gallery that displays the collection. Alone this works perfectly.
But when I select a specific contact from the Gallery of Contracts, I set a variable (_contEdit) so the form is not blank, but it displays the current SharePoint list item for editing.
If I put
 

 

If(
 _contEdit,
 {},
 LookUp(Contracts, Gallery1.Selected.ID = ID, contractType)
)

 

As a default value for the Property of the Gallery, I get an error ' expected a value compatible with items'
I would like to have the "Add New" show nothing selected and when in Edit Mode have the SharePoint Source Data value from the list shown.
I hope that makes sense.
Categories:
  • Hack-7 Profile Picture
    216 Super User 2025 Season 1 on at
    Re: Gallery Selected Item by default

    @gcmfaizan Yes, that was one of the issues...  And I did see my mistake seconds after I posted this question.  

    But, I was making a mistake on my Lookup().  I had my other list set as the data source and not the built collection.

     

    Sometimes it helps to write the question out to find the answers!  Cheers

  • Verified answer
    gcmfaizan Profile Picture
    1,022 on at
    Re: Gallery Selected Item by default

    @Hack-7 you are doing right but you do it vise-versa do it like this:

    If(_contEdit, LookUp(Contracts, ID = Gallery1.Selected.ID, contractType), {})

     

    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

     

    Thanks!

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,670 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard