web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to filter data tab...
Power Apps
Answered

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

(0) ShareShare
ReportReport
Posted on by 2

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?

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

    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 Profile Picture
    2 on at

    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.

  • Verified answer
    v-jefferni Profile Picture
    on at

    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.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard