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 / Gallery Search and Fil...
Power Apps
Answered

Gallery Search and Filter y date if Toggle is 'true'

(0) ShareShare
ReportReport
Posted on by 6

HI,

I have a gallery that has the following set - 

 

Search(Filter(Table2,

         DateValue(

            Text(Migration_x0020_Date)) = Today()

         ),TextSearchBox1_8.Text,"displayname")

 

This works, but what i would like to do is add a Toggle button, so that if it is true - then the filter is set to = Today() and if its not true it should not filter the list (i.e. show everything), but i am struggling to understood where and how best to put my If statement.

 

Appreciate your guidance\input.

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,925 on at

    Try:

    If(Toggle1.Value=true,

    Search(Filter(Table2, DateValue(

      Text(Migration_x0020_Date)) =Today()  ),TextSearchBox1_8.Text,"displayname"),Table2)

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

     

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @tredgold ,

    Do you want to add a Toggle button to control the date filter within your Filter function?

     

    I have made a test on my side, please consider take a try with the following workaround:

    Set the Items property of the Gallery to following:

    Search(
     Filter(
     Table2,
     If(
     Toggle1.Value = true,
     DateValue(Text(Migration_x0020_Date)) = Today(),
     true
     )
     ),
     TextSearchBox1_8.Text,
     "displayname"
    )

     

    Please try above solution, then check if the issue is solved.

     

    Best regards,

  • tredgold Profile Picture
    6 on at

    Thanks very much for the suggestion, this almost did what i needed but it wasn't allowing me to search when the toggle button was off, so i took what you provided and amended the "false" action slightly so i could still search on all records returned - 

     

    If(Toggle1.Value= true ,Search(Filter(Table2,DateValue(Text(Migration_x0020_Date))=Today()),TextSearchBox1_8.Text,"displayname"),Search(Table2,TextSearchBox1_8.Text,"displayname"))
     
    The above is now working as i wanted in my app, Again thank you for the help as your suggestion pointed me in the right direction.
  • eka24 Profile Picture
    20,925 on at

    Mark the solution

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @tredgold ,

    Have you taken a try with the solution I provided above?

     

    Based on the needs that you mentioned, I think the formula I provided above could achieve your needs easily. Please try a try with it, if you have any issue with the solution, please feel free to let me know here.

     

    If you have solved your problem, please consider go ahead to click "Accept as Solution" to identify this thread has been solved.

     

    Best regards,

  • tredgold Profile Picture
    6 on at

    HI, Yes i have tested the solution you provided and find this works and is a simpler solution than the alternative i had suggested - so thank you very much.

    I have marked it as the accepted solution.

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

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard