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.

 

rahulk37
Frequent Visitor

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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (3,989)