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 / Nested Search with Cho...
Power Apps
Answered

Nested Search with Choice and Date Column along with sort in powerapps - Need help

(0) ShareShare
ReportReport
Posted on by 71

I need help with search function in grid gallery control.

 

I have designed student records grid cell table using gallery.

 

I am providing search and sort capability to user to search student record using search field under each grid column and also sort individual column in ascending or descending order.

 

I have search text field under every column of Gallery grid so user can search student details using name, age, sex, country, etc.

I am using search function in nested form so that user can search based on one column and then also filter/search second column criteria and can search/filter on third column, and search on fourth column, etc.

 

Example:

Search scenario:
User gives Student Name = Student_A      --> Outcome  Student_AA, Student_AB, Student_AC

User gives Age = 18   --> Outcome Student_AA, Student_AB

User gives Sex = F  --> Outcome Student_AB

 

I am also using 'sortbycolumn' function to allow user to sort each column (before or after search results) using icon on each grid gallery column.

The below code works when I use Text type column from dataverse data table. 

  

Whenever I am using Numeric column or choice column or data/time column from dataverse table in search fields code, I get following error:

"The function 'search' has some invalid arguments"

 

I am using following function:
 
SortByColumn(

Search(

Search(

'Mydataversetablename',

Txtbox_Search_Name.Text, //Search Student Name --Text Field in Dataverse table

"std_name"

),

Txtbox_Search_Country.Text, //Search Student Country -- Text Field in Dataverse table

"std_country"

),

Txtbox_Search_Std_Age.Text, //Search Student based on Age -- Numeric field in Dataverse table

"std_age"

),

Txtbox_Search_Std_DoB.Text, //Search Student based on Date of Birth -- Date/Time field in Dataverse table

"std_Date_of_Birth"

),

Txtbox_Search_Std_SeX.Text, //Search Student based on Sex -- Choice field in Dataverse table

"std_sex"

),




Sort_Column_Name,

Sort_Direction_A_D

)


 

I am using following code in ITEMS of my gallery grid:

 

 

I tried combining Search and Filter code however I could not get 'right' result when user gives input in text field so I tried to solve it using search function only. 

Any suggestion or ideas to update/change my code to provide search function for each columns and also allow user to sort each columns independently.

 

I want to give search capability to user under each column (using text box for search text) of the student gallery grid and allow user to combine multiple column search field together.

 

BradAugustene_0-1698290290328.png

 

BradAugustene_1-1698290326713.png

 

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,353 Super User 2025 Season 2 on at

    Hi @BradAugustene 

     

    Your Function for searching appears bad to me.

    Take a look I reformatted so I could see it better

    You cannot add multiple Search String values into a Search, you can identify multiple columns to LOOK in for the text, but not multiple.

     

    But below, I dont know where those 3 lines I marked up are supposed to go to? They do not map to searches. Did you mean to wrap 5 searches?

    SortByColumn(
    
     Search(Search('Mydataversetablename', Txtbox_Search_Name.Text, "std_name"), Txtbox_Search_Country.Text, "std_country"), <== this ends the double search
    
     Txtbox_Search_Std_Age.Text, "std_age"), <== this appears to go to nothing
    
     Txtbox_Search_Std_DoB.Text, "std_Date_of_Birth"),<== this appears to go to nothing
    
     Txtbox_Search_Std_SeX.Text, "std_sex" <== this appears to go to nothing
    
     ),
    
     Sort_Column_Name,
    
     Sort_Direction_A_D
    
    )
    
    Like This?
    SortByColumn(
    
    Search(Search(Search(Search(Search('Mydataversetablename', Txtbox_Search_Name.Text, "std_name"), Txtbox_Search_Country.Text, "std_country"), Txtbox_Search_Std_Age.Text, "std_age"), 
     Txtbox_Search_Std_DoB.Text, "std_Date_of_Birth"),
    
     Txtbox_Search_Std_SeX.Text, "std_sex"),
    
     Sort_Column_Name,
    
     Sort_Direction_A_D
    
    )

     
    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • Verified answer
    v-mengmli-msft Profile Picture
    on at

    Hi @BradAugustene ,

     

    I just modified my reply.

    Please try this:

     

    SortByColumn(
    
    Search(
    Search(
    Search(
    Search(
    Search(
    
     AddColumns('Mydataversetablename',"testDate",Text(std_Date_of_Birth),"testChoice",Text(std_sex)),
    
     Txtbox_Search_Name.Text, //Search Student Name --Text Field in Dataverse table
    
     "std_name"
    
     ),
    
     Txtbox_Search_Country.Text, //Search Student Country -- Text Field in Dataverse table
    
     "std_country"
    
     ),
    
     Value(Txtbox_Search_Std_Age.Text), //Search Student based on Age -- Numeric field in Dataverse table
    
     "std_age"
    
     ),
    
     Txtbox_Search_Std_DoB.Text, //Search Student based on Date of Birth -- Date/Time field in Dataverse table
    
     "testDate"
    
     ),
    
     Txtbox_Search_Std_SeX.Text, //Search Student based on Sex -- Choice field in Dataverse table
    
     "testChoice"
    
     ),
    
     Sort_Column_Name,
    
     Sort_Direction_A_D
    
    )

     

     

     

    Best regards,

    Rimmon Li 

  • BradAugustene Profile Picture
    71 on at

    Hi Rimmon Li

    Thank you very much for helping with updated code.
    Your updated code works perfect.
    It is doing exactly as expected.
    I hope it will also help me in saving (using patch function) any changes done by user in any column cell in data grid .
    THNK YOU.👍👏

  • Michael E. Gernaey Profile Picture
    53,353 Super User 2025 Season 2 on at

    So weird,, i answered first and correctly /

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 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard