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 / How do i change a sear...
Power Apps
Answered

How do i change a search field for a gallery?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

In my gallery, my SortByColumns() code looks like this

SortByColumns(Search([@testTable], TextInput5.Text, "current_year","current_month","current_week"), "current_year", If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))

 

current_year, _month, and _week are all numeric (ie 1,2,3)

 

 

In my gallery, I reformatted the month number to text as shown in the screenshot below

raspberryPie_0-1699924470554.png

To reformat the numbers to text, I used this code:

Text(DateValue(ThisItem.current_month & "/1/" & ThisItem.current_year),"mmmm")

 

How do I change the "current_month" field in the SortByColumns() code to let users search by month name instead of month number?

 

 

 

Categories:
  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    You can add the formatted month to a new column in the data source:

    SortByColumns(Search(AddColumns([@testTable], "NewMonth", Text(DateValue(ThisRecord.current_month & "/1/" & ThisRecord.current_year),"mmmm")), TextInput5.Text, "current_year","current_month","current_week","NewMonth"), "current_year", If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))

     

    Best regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    In the gallery, I set the selected value to a variable. The code is below:

    Navigate(detailData, ScreenTransition.None); Set(varRecord1, ThisItem)

     

    detailData is a page to see the the columns for the selected row.

     

    When I add the new column through your code, for some reason this creates an error. The error is shown below.

    raspberryPie_0-1699941965246.png

     

    Any idea why this happens?

  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    It's because the selected item has different data structure (columns) compared with the original data source of the Form. You can change varRecord1 of Item as below:

    LookUp(testTable, ID = varRecord1.ID)

     

    Best regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    raspberryPie_0-1699943370152.png

    ID isnt recognised in LookUp().

    My data doesnt have an ID field. But is it present by default?

     

    Any suggestions?

  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    There must be a unique key column in that table, you can use it instead of ID in that formula.

     

    Best regards,

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 224 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 126

Last 30 days Overall leaderboard