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 / Adding a search bar to...
Power Apps
Answered

Adding a search bar to a gallery error

(0) ShareShare
ReportReport
Posted on by 121

Hi all,

 

I am trying to add a search bar function to a gallery - so as the user can search for a date in the data set and view that entry. However, I am getting some errors when trying to add this function.

 

I have attached some screenshots to show what I have tried.

 

The table I am searching in is a SP list.

 

Please let me know if you require any further information.

 

Thanks in advance

 

jolebe09_0-1684143586013.png

 

 

Categories:
I have the same question (0)
  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @jolebe09,

     

    The Search() function expects the column to be of type Text. Should you want to give the user the possibility to filter via Date, you might want to use a DatePicker control and a Filter() function instead:

     

    Filter(
     SolihullBS1,
     MonShiftStart = DatePickerControl.SelectedDate //Rename DatePickerControl to the correct name
    )

     

    If this solves your question, would you be so kind as to accept it as a solution.

    Thanks!

  • CU-18081211-6 Profile Picture
    9,272 Moderator on at

    @jolebe09 ,

    Search() function is not delegable to SharePoint and using this will raise a delegation warning from the app. 
    You need to reconsider your scenario and if it suitable to use startswith() function.

     

  • Sundeep_Malik Profile Picture
    6,501 on at

    Hey @jolebe09 

     

    Instead of Search, you can use a Filter function here.

     

     

    Filter(SolihullBS1, BS1SearchBox.Text="MONShiftStart")

     

    I hope this helps 🙂

  • jolebe09 Profile Picture
    121 on at

    Hi @LaurensM thanks for getting back to me! 

    I'm afraid I'm not familiar with the date picker function - would this be the TextInput card I have created as the search bar?

    Apologies, thank again.

    J

  • jolebe09 Profile Picture
    121 on at

    Hi @Sundeep_Malik thanks so much for your response!

     

    I have tried your solution and I'm afraid I'm unable to search/filter anything. As the gallery is empty - when the search bar is empty and if I try to search an entry in the gallery.

     

    Do you know why this might be? Thank you again!!

     

    jolebe09_0-1684145091547.png

     

  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @jolebe09,

     

    A DatePicker is a Power Apps control (just as TextInput is one), which would allow you to filter the Date column based on a date selection (should MONShiftStart be a date column). Filtering via a TextInput is mainly used to filter/search through text fields or choice column values.

     

    In theory, you could create a text value of your date column - but be aware that this is not delegable (& a DatePicker is better UI/UX wise):

    Search(
     AddColumns(
     SolihullBS1,
     "MonShiftStartText",
     Text(MonShiftStart, "dd/mm/yyyy")
     )
     BS1SearchBox.Text,
     "MonShiftStartText"
    )

    The user can now search based on the date text field (searchtext has to follow the day/month/year format).

     

    I hope this helps!

  • jolebe09 Profile Picture
    121 on at

    Hi @LaurensM thank you again!!

     

    I'm really sorry, but it's still flagging a load of errors.

    Could this also be that there is a time attached to the date?

    Like this 

    jolebe09_0-1684147089516.png

     

    For reference - this is how the list is set up

    jolebe09_0-1684147242828.png

     

    Thanks again

    J

  • Sundeep_Malik Profile Picture
    6,501 on at

    @jolebe09 

     

    Though @LaurensM solution is the most appropriate in your case. But if you want to try the following you can:

     

    If(IsBlank(BS1SearchBox.Text),
    SolihullBS1,
    Filter(L2, BS1SearchBox.Text in MONShiftStart)

    )

     

     

    or

     

    If(IsBlank(BS1SearchBox.Text),
    SolihullBS1,
    Search(SolihullBS1,BS1SearchBox.Text,"MONShiftStart")

    )

    @LaurensM What are your views on this??

  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    @jolebe09,

     

    I just noticed a missing comma in my previous code (see red):

     

    Search(
    AddColumns(
    SolihullBS1,
    "MonShiftStartText",
    Text(MonShiftStart, "dd/mm/yyyy")
    ),
    BS1SearchBox.Text,
    "MonShiftStartText"
    )

     

    Since it is a DateTime field, in the case of a DatePicker use:

    Filter(
     SolihullBS1,
     //Rename DatePickerControl to the correct name
     MonShiftStart >= DatePickerControl.SelectedDate 
     && MonShiftStart <= (DatePickerControl.SelectedDate + Time(23,59,59))
    )

     

    I hope that helps!

  • jolebe09 Profile Picture
    121 on at

    @LaurensM thanks so much!! And thank you for your patience!

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 494

#2
WarrenBelz Profile Picture

WarrenBelz 352 Most Valuable Professional

#3
11manish Profile Picture

11manish 323

Last 30 days Overall leaderboard