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 / Add blank record to ga...
Power Apps
Answered

Add blank record to gallery and have it sorted so that the blank row is on top

(0) ShareShare
ReportReport
Posted on by 1,512

I have a gallery of names and addresses in a gallery with all of the controls in the gallery as textinput so that the records can easily be edited.  I also want to click a button and generate a new blank row (record) in the gallery.

This is the code now that is working to display all existing records.

SortByColumns(
 If(
 IsBlank(TextInput1.Text),
 Filter(
 'Home Energy Assessments',
 'Assessment Status'.Value = "Pending Assessment"
 ),
 Search(
 Filter(
 'Home Energy Assessments',
 'Assessment Status'.Value = "Pending Assessment" &&
 ('Last Name' = TextInput1.Text ||
 'Account Number' = TextInput1.Text ||
 'Premise Address' = TextInput1.Text)
 ),
 TextInput1.Text,
 "Title",
 "Premise_x0020__x000a_Number",
 "Account_x000a_Number",
 "Premise_x000a_Address"
 )
 ),
 "Title",
 Ascending
)

 

I want to be able to click on a button and create a blank item in my SharePoint list and have that row at the top of the gallery and the rest of the items in ascending order by the title (Last Name) field.

 

Is this possible?  I need the code for the button and the gallery.

 

My first attempt at the button code was this

 

Patch(
 'Home Energy Assessments',
 Defaults('Home Energy Assessments'),
 {
 Title: ""
 }
)
Categories:
I have the same question (0)
  • TheRobRush Profile Picture
    11,128 Moderator on at

    **EDIT**

    Removing the stuff that did not work, so others looking for solution won't waste their time with them

  • Dorinda Profile Picture
    1,512 on at

    I tried this and got nothing but errors

     

    ClearCollect(Last(), Patch('Home Energy Assessments', Defaults('Home Energy Assessments'), { Title: "" }));
    ClearCollect(MyCollection, Collect(Filter(Last(), !IsBlank(Title))))
  • TheRobRush Profile Picture
    11,128 Moderator on at

    **EDIT**

    Removing the stuff that did not work, so others looking for solution won't waste their time with them

  • Dorinda Profile Picture
    1,512 on at

    do I need to change any of the code on the gallery?

  • Verified answer
    TheRobRush Profile Picture
    11,128 Moderator on at

    Oh Yah, your gallery is referencing the source directly, so youd either need to run the current code in your gallery before loading it as a clearcollect() that way its always referencing a collection. OR and this might be easier for you. wrap your current gallery code in a AddColumn, would look like this

     

    (Might have some syntaxt to fix becuase i wrote it on my own splist to show you)

     

    Sort(AddColumns(
    SortByColumns(
     If(
     IsBlank(TextInput1.Text),
     Filter(
     'Home Energy Assessments',
     'Assessment Status'.Value = "Pending Assessment"
     ),
     Search(
     Filter(
     'Home Energy Assessments',
     'Assessment Status'.Value = "Pending Assessment" &&
     ('Last Name' = TextInput1.Text ||
     'Account Number' = TextInput1.Text ||
     'Premise Address' = TextInput1.Text)
     ),
     TextInput1.Text,
     "Title",
     "Premise_x0020__x000a_Number",
     "Account_x000a_Number",
     "Premise_x000a_Address"
     )
     ),
     "Title",
     Ascending
    ),
     "NewColumn", Switch(Title,Blank(),0,1)),NewColumn,Ascending)

     

    ***EDITED TO FIX A CODE TYPO

     

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Ignore my first suggestion and try the above in your gallery items

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Edited the above because I had 2 commas here instead of 1, in case you copied the code before i fixed

    TheRobRush_0-1676656622823.png

     

  • Dorinda Profile Picture
    1,512 on at

    Yeah I found that one, now the only issue I am facing is in all of my patches 

     

    Patch('Home Energy Assessments',ThisItem,{'Disabled Discount':TextInput3_3.Text})

    give me errors

    Dorinda_0-1676657164807.png

     

  • TheRobRush Profile Picture
    11,128 Moderator on at

    **EDIT**

    Removing the stuff that did not work, so others looking for solution won't waste their time with them

  • Dorinda Profile Picture
    1,512 on at

    Dorinda_0-1676657817367.png

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 429 Most Valuable Professional

#2
11manish Profile Picture

11manish 191 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 122 Super User 2026 Season 2

Last 30 days Overall leaderboard