cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rahulk37
Frequent Visitor

How to filter data table or gallery using on select event of button

So I have a data table which I want to filter on the basis of a column and Table 1 is placed under items of Data Table

I am using this query but not able to filter out :

 

"Update Context({ Table 1:Sort(Filter(Data Table 3, Date Value('Last Updated On')=Today()), 'Last Updated On',Descending )}"

 

 


Can anybody help me in this?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @rahulk37 ,

 

Do you want to use a button to decide whether filter the table to show last 7 days’ records or the whole table?

If you do, please follow the steps:

1.    Set the Button’s OnSelected: 

 

UpdateContext({LastUpdatedIn7:!LastUpdatedIn7})

 

2.    Set the table or gallery’s Items:

 

SortByColumns(If(LastUpdateIn7, Filter(Table1,Date Value('Last Updated On')>=Today()-7),Table1,) ”Last Updated On”,Descending)

 

3.    Set the Text of the Button(if it is a button rather than an icon):

 

If(LastUpdatedIn7,”SHOW ALL” , “SHOW LAST 7 DAYS’”)

 

When the screen shows up, the Button displays “SHOW LAST 7 DAYS’” while the gallery shows all records, once click the button, gallery items turn to records in last 7 days and button text change to “SHOW ALL”

 

Best regards,
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution  to help the other members find it more.

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

3 REPLIES 3
eka24
Super User
Super User

Can you explain further what you want the button to do after clicking?

Generally filter will be;

 

Sort(Filter(Data Table 3, Text('Last Updated On',ShortDate) =Text(Today(),ShortDate)), Descending 

So give further information on the button

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

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.

 

Whenever I click the button , I want the Data table to be filtered on the basis of a column( Last updated on). Last updated is a date column and in the data table , records should come which were last updated in last 7 days. In items section of data table I have table 1 which is table from my excel file. 

 

Whenever user enters a record , the last updated column holds the current date and time value for that record.

I am able to filter it by using query :

Sort(Filter(Table 1, Date Value('Last Updated On')>=Today()-7), 'Last Updated On',Descending ) ,

under items section of data table but I want to get it done with button.

The filter which you gave is not working.

Hi @rahulk37 ,

 

Do you want to use a button to decide whether filter the table to show last 7 days’ records or the whole table?

If you do, please follow the steps:

1.    Set the Button’s OnSelected: 

 

UpdateContext({LastUpdatedIn7:!LastUpdatedIn7})

 

2.    Set the table or gallery’s Items:

 

SortByColumns(If(LastUpdateIn7, Filter(Table1,Date Value('Last Updated On')>=Today()-7),Table1,) ”Last Updated On”,Descending)

 

3.    Set the Text of the Button(if it is a button rather than an icon):

 

If(LastUpdatedIn7,”SHOW ALL” , “SHOW LAST 7 DAYS’”)

 

When the screen shows up, the Button displays “SHOW LAST 7 DAYS’” while the gallery shows all records, once click the button, gallery items turn to records in last 7 days and button text change to “SHOW ALL”

 

Best regards,
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution  to help the other members find it more.

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (5,414)