cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gorilla_8
Level 8

ACTIVATE A FILTER BY 7 DAYS ON A DATE

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

19 REPLIES 19
eka24
Level 10

Re: ACTIVATE A FILTER BY 7 DAYS ON A DATE

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.

Community Support Team
Community Support Team

Re: ACTIVATE A FILTER BY 7 DAYS ON A DATE

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Gorilla_8
Level 8

Re: ACTIVATE A FILTER BY 7 DAYS ON A DATE

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
Community Support Team
Community Support Team

Re: ACTIVATE A FILTER BY 7 DAYS ON A DATE

Hi @Gorilla_8 ,

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

And the field's data type?

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Gorilla_8
Level 8

Re: ACTIVATE A FILTER BY 7 DAYS ON A DATE

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)
Community Support Team
Community Support Team

Re: ACTIVATE A FILTER BY 7 DAYS ON A DATE

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Gorilla_8
Level 8

Re: ACTIVATE A FILTER BY 7 DAYS ON A DATE

Thanks for The reply, but I already have another filter on my collection... There no way to separate those filter to another?
Community Support Team
Community Support Team

Re: ACTIVATE A FILTER BY 7 DAYS ON A DATE

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Gorilla_8
Level 8

Re: ACTIVATE A FILTER BY 7 DAYS ON A DATE

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"

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (10,034)