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 / ACTIVATE A FILTER BY 7...
Power Apps
Unanswered

ACTIVATE A FILTER BY 7 DAYS ON A DATE

(0) ShareShare
ReportReport
Posted on by

Hey guys, I need to activate a filter in PowerApps so that when it starts up with the application, make a date filter for today's date (today + 7) and disable it when it clicks a button

 

There is possible?

 

filter_date+7.png

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

    Please you formula will not work because you are filtering a textbox. If you want to show (today + 7) then use:

    DateAdd(Today(),7)
     

    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-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @Gorilla_8 ,

    Do you want to filter data based on date( today+7)?

    Could you tell me

    1)which field do you want to filter based on date? this field's data type?

    2)where do you want to display the filtered data?

     

    1)If you want to filter based on date, you need to transfer the field to date type.

    The filter formula should be like:

    Filter(tablename,fieldname=DateAdd(Today(),7,Days))

    //please replace with your teablename, fieldname. Field in this formula should be date type.

     

    2)Filter function will return a table, not a value. 

    So please not use this formula in a label's Text.

    You need to use this filter function in a gallery's Items, data table's Items, etc.

     

     

    Best regards,

  • Gorilla_8 Profile Picture
    on at
    Hey guys, I didn't notice The value of a label wont workout...

    But I can try to activate The filter when The APP open, and The user clicks on button The filter not activate anymore...


    I think I can use a toggle for that
  • v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @Gorilla_8 ,

    Ok, please tell me where do you want to put the filtered result?

    And the field's data type?

     

    Best regards,

  • Gorilla_8 Profile Picture
    on at
    Okay, I want to show in gallery, and The type of data is text I think, I already have a filter data, and works well with date value (data início real)
  • v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @Gorilla_8 ,

    1)set the app's OnStart:

    ClearCollect(collection,Filter(tablename,DateValue(fieldname)=DateAdd(Today(),7,Days)))
    //if it is text type, you need to use DateValue() to transfer

    2)insert a toggle

    set the toggle's OnCheck:

    ClearCollect(collection,Filter(tablename,DateValue(fieldname)=DateAdd(Today(),7,Days)))

     set the toggle's OnUncheck:

    ClearCollect(collection,tablename)

    set the toggle's Default:

    true

    3)set the gallery's Items:

    collection

    //please replace with your tablename, fieldname 

     

    Then at the beginning the gallery will display the filtered table, if you turn off the toggle, the gallery will display the table, if you turn on the toggle, it will display the filtered table again.

     

    Best regards,

  • Gorilla_8 Profile Picture
    on at
    Thanks for The reply, but I already have another filter on my collection... There no way to separate those filter to another?
  • v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @Gorilla_8 ,

    Whether this collection is related to your filtered items(today+7)?

    Collection is just a collection name in my test.

    You could name it by other names. If two collections are not the same name, they will not affect each other.

    Try this:

    1)set the app's OnStart:

    ClearCollect(collection2,Filter(tablename,DateValue(fieldname)=DateAdd(Today(),7,Days)))
    //if it is text type, you need to use DateValue() to transfer

    2)insert a toggle

    set the toggle's OnCheck:

    ClearCollect(collection2,Filter(tablename,DateValue(fieldname)=DateAdd(Today(),7,Days)))

     set the toggle's OnUncheck:

    ClearCollect(collection2,tablename)

    set the toggle's Default:

    true

    3)set the gallery's Items:

    collection2

    //please replace with your tablename, fieldname 

     

     

    Best regards,

  • Gorilla_8 Profile Picture
    on at

    hi @v-yutliu-msft , Thanks for the reply!

     

    But my gallery is like this:

     

    SortByColumns(
     If(
     drpFilter.Selected.Value = "Data início";
     Filter(
     collTaskListForGallery;
     DateValue(DatadeIníciodaTarefa) = DatePicker1.SelectedDate
     );
     collTaskListForGallery
     );
     "TrabalhoPercentualdaTarefaConcluído";
     If(
     radioporcentagem.Selected.Value = "Maior";
     Descending;
     radioporcentagem.Selected.Value = "Menor";
     Ascending
     );
     "OrdemdeManutenção";
     If(
     radiorodemOM.Selected.Value = "Maior";
     Descending;
     radiorodemOM.Selected.Value = "Menor";
     Ascending
     );
     "TrabalhoPercentualdaTarefaConcluído";
     If(
     toggle_porcentagem.Value = true;
     Ascending;
     toggle_porcentagem.Value = false;
     Descending
     )
    )

     

    There is already code on it!

     

    And my toggle name is this: "toggle_date"

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

    Hi @Gorilla_8 ,

    Do you want these feathers?

    1)when drpFilter.Selected.Value = "Data início" and (at the beginning or turn on the toggle)

    the gallery filter based on today+7

    2)when drpFilter.Selected.Value = "Data início" and turn off the toggle

    the gallery filter based on datepicker

    3)when drpFilter.Selected.Value is not "Data início"

    gallery will display collTaskListForGallery directly

     

    If so, try this:

    1)set the app's OnStart:

    Set(var,true)

    set toggle's OnCheck:

    Set(var,true)

     set toggle's OnUncheck:

    Set(var,false)

    set toggle's Default:

    true

    //at the beginning the var is true, the toggle is on. If you turn off the toggle, the var will be false. If you turn on the toggle, the var will be true. When var is true(toggle is on), gallery will filter based on today+7, when var is flase(toggle is off), gallery will filter based on datepicker.

     

    2)set the gallery's Items:

    SortByColumns(
     If( 
     drpFilter.Selected.Value = "Data início"&&var;
     Filter(
     collTaskListForGallery;
     DateValue(DatadeIníciodaTarefa) = DateAdd(Today(),7,Days)
     );
     drpFilter.Selected.Value = "Data início"&&!var;
     DateValue(DatadeIníciodaTarefa) =DatePicker1.SelectedDate;
     collTaskListForGallery
     );
     "TrabalhoPercentualdaTarefaConcluído";
     If(
     radioporcentagem.Selected.Value = "Maior";
     Descending;
     radioporcentagem.Selected.Value = "Menor";
     Ascending
     );
     "OrdemdeManutenção";
     If(
     radiorodemOM.Selected.Value = "Maior";
     Descending;
     radiorodemOM.Selected.Value = "Menor";
     Ascending
     );
     "TrabalhoPercentualdaTarefaConcluído";
     If(
     toggle_porcentagem.Value = true;
     Ascending;
     toggle_porcentagem.Value = false;
     Descending
     )
    )

     

     

     

    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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard