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 / FILTER COLLECTION(GALL...
Power Apps
Answered

FILTER COLLECTION(GALLERY) + 7 DAYS (WHEN THE USER SELECT A DATE)

(0) ShareShare
ReportReport
Posted on by

Hey

 If(
 drpFilter.Selected.Value = "Data início";
 Filter(
 collTaskListForGallery;
 DateValue(DatadeIníciodaTarefa) = DateAdd(Today();7;Days)
 );

guys, There is possible to filter a gallery by selected a date on "date picker" + 7 days and show the data?

 

There is my code: (he is not filtering)

 

 

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    69,485 Most Valuable Professional on at

    Dates in Power Apps will always include Dates and Times, so using an '=' almost never works.  Try either '<=' or '>=' instead depending on whether you are checking for something within 7 days or beyond 7 days.

  • Gorilla_8 Profile Picture
    on at

    Hi @Pstork1 , thanks for the reply! Keep the same result, showing nothing on my gallery...

  • Pstork1 Profile Picture
    69,485 Most Valuable Professional on at

    Did you try both >= and <=?  One of them should work unless the filter isn't being applied based on the dropdown.

     

    • How big is the list? Filters that involve dates are not delegable.
    • Are you sure that DatadeIníciodaTarefa is a variable that contains a valid date as text
    • Does it work if you remove the If() around the outside?  Could the check on the dropdown choice be misfiring?
  • Gorilla_8 Profile Picture
    on at

    Hi @Pstork1 . Yes, I try both '>=' and '<=' and the '<=' shows all the collection instead of filtering.

     

    Like this:

     

    the code:

     

     

     If(
     drpFilter.Selected.Value = "Data início";
     Filter(
     collTaskListForGallery;
     DateValue(DatadeIníciodaTarefa) <= DateAdd(
     Today();
     7;
     Days
     )
     );
     collTaskListForGallery
     )

     

     

    The result:

     

    date.png

     

     

    • How big is the list? Filters that involve dates are not delegable.
      This one has 300 items, but gonna be more than 3000 sometimes...

    • Are you sure that DatadeIníciodaTarefa is a variable that contains a valid date as text
      Yes, its valid text, I test putting a label on my gallery to show the date, and there is a date


    • Does it work if you remove the If() around the outside? Could the check on the dropdown choice be misfiring?
      No, he shows all the same way

      See on this code:

     

    Filter(
     collTaskListForGallery;
     DateValue(DatadeIníciodaTarefa) <= DateAdd(
     Today();
     7;
     Days
     )
     )​

     


    The result:

    seeonthis.png

    The label I mentioned: "27/03/2020" and the result is showing all the gallery.

     

     

     

  • Gorilla_8 Profile Picture
    on at

    Sorry for my last answer ... See the error...

     

    seeonthis.png

     

    It's not filtering...

  • Verified answer
    Pstork1 Profile Picture
    69,485 Most Valuable Professional on at

    First, if you expect the data source to grow larger than 500-2,000 records then filtering by date won't ever work since it is non-delegable.  So it may be a waste of time and you'll need to look for a different solution.

     

    But it looks like the filter is working as expected when using <=.  It shows all the records because all the dates are less than 7 days out.  If you want to filter the records then the filter needs to be a comparison of some field in the record with the date or date +7 days.  If you do the comparison to a value you type in its always going to be either true or false for all the records.  If you want to filter the records where the date in the record is less than or greater than 7 days of the date you type in then use that date, not Today.

  • Gorilla_8 Profile Picture
    on at

    Hi @Pstork1 , yes the filter by '<=' is filtering, correct, thanks for the help.

     

    But my necessity is when the user selects a date + 7 days to show the records...

     

    Its gonna be the same?

  • Gorilla_8 Profile Picture
    on at

    Like this I mean:

     

     Filter(
     collTaskListForGallery;
     DatePicker1.SelectedDate >= DateAdd(
     Today();
     7;
     Days
     )
     )
  • Pstork1 Profile Picture
    69,485 Most Valuable Professional on at

    But that formula doesn't compare against anything on the record itself, so it will always be either true or false for every record.  To filter you need to compare the date to a date that is specific to each record.

  • Gorilla_8 Profile Picture
    on at

    Hi @Pstork1 , yes, I try to filter by another way and work it, but I need to filter by "today" + 7 days like this code:

     

     Filter(
     collTaskListForGallery;
     DatePicker1.SelectedDate >= DateAdd(DateValue(DatadeIníciodaTarefa);7;Days)
     );
     collTaskListForGallery
     );

     

    And you help me a lot to solve this problem, if you wanna I make a new post here:

    https://powerusers.microsoft.com/t5/Building-Power-Apps/FILTER-A-GALLERY-TODAY-7-DAYS/m-p/512296

    Thanks for your time and explaining @Pstork1 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 846

#2
Valantis Profile Picture

Valantis 532

#3
Haque Profile Picture

Haque 410

Last 30 days Overall leaderboard