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 / Data Table filtering a...
Power Apps
Answered

Data Table filtering a Gallery

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi All,

I have this Data Table I created to generate row numbers in a gallery. The Data Table is called DataTable1 for now. I have the following in Items:

ForAll(Sequence(CountRows(ccAuditTest)), Patch(Last(FirstN(ccAuditTest, Value)), {Row: Value}))

 

I need to filter this Data table to only filter using another Gallery selected ID. Filter(ccAuditTest, ID = MainGallery.Selected.ID)

 

How do I combine these two so I can get filter I need plus the Row count? I hope this makes sense. Thank you

Categories:
  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Anonymous 

     

    Filter(ccAuditTest, ID = MainGallery.Selected.ID)

     Does this always return 1 row though? Or are there cases where it might return more than one row?

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Anonymous 

     

    If you really want the count, you might be able to do this:

     

    ForAll(Sequence(CountRows(ccAuditTestVar)), Patch(Last(FirstN(ccAuditTestVar, Value)), {Row: Value}))

     

     

    And from wherever you want the Filter to be triggered:

     

    Set(ccAuditTestVar,Filter(ccAuditTest, ID = MainGallery.Selected.ID))

     

    I think the above Filter always returns just 1 record, so if you want, you can test with another Filter that returns more than 1 record,to see if it really works. 

     

     See if it helps @Anonymous 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @poweractivate 
    Thanks for responding. 

    On the DataTable1 - Items:  Filter(ccAuditTest, ID=MainGallery.Selected.ID)

     

    Screen OnVisible: 

    ForAll(Sequence(CountRows(ccAuditTest)), Patch(Last(FirstN(ccAuditTest, Value)),{RowNumber: Value}));

     

    Now, the Row count on the DataTable1 is showing no numbers, just blank. Its filtering like it should now, but no Row number.  Did I miss something?

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Anonymous 

     

    Try this

     

    Screen OnVisible: 

    Set(ccAuditTestVar,Filter(ccAuditTest, ID=MainGallery.Selected.ID));
    ForAll(Sequence(CountRows(ccAuditTestVar)), Patch(Last(FirstN(ccAuditTestVar, Value)),{RowNumber: Value}));

     

    On the DataTable1 - Items:  

    ccAuditTestVar

    See if it helps @Anonymous 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @poweractivate 

    Screen OnVisible: 

    Set(ccAuditTestVar,Filter(ccAuditTest, ID=MainGallery.Selected.ID));
    ForAll(Sequence(CountRows(ccAuditTestVar)), Patch(Last(FirstN(ccAuditTestVar, Value)),{RowNumber: Value}));

     

    On the DataTable1 - Items:  

    ccAuditTestVar


    I don't have anything showing in the DataTable now.  Not sure how to do this now. 

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Anonymous 

     

    Try ClearCollect instead of Set, see if it works then.

     

    Screen OnVisible: 

    ClearCollect(ccAuditTestCollection,Filter(ccAuditTest, ID=MainGallery.Selected.ID));
    ForAll(Sequence(CountRows(ccAuditTestCollection)), Patch(Last(FirstN(ccAuditTestCollection, Value)),{RowNumber: Value}));

     

    On the DataTable1 - Items:  

    ccAuditTestCollection

     

    Also, if trying to see results in the editor right away, make sure Screen1 OnVisible is being fired after making changes, so if needed, make a blank screen, and toggle between the blank screen and Screen1 in the editor, to trigger OnVisible of Screen1 and the changes to take effect.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @poweractivate 
    I'm sorry, that didn't work. I'm not sure what to do now. 

  • Verified answer
    poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Anonymous 

     

    Try like this

    //OnVisible Screen1
    
    ClearCollect(varCollection,ForAll(Sequence(CountRows(ccAuditTest)), Patch(Last(FirstN(ccAuditTest, Value)), {Row: Value})))
    
     
    
    //I need to filter this Data table to only filter using another Gallery selected ID. 
    //Use the below from wherever you want to have the Filtered Record with the row number 
    
    Filter(varCollection, ID = MainGallery.Selected.ID)

     See if it helps

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @poweractivate - Thank you!

    Thank you for sticking with me. Its working now. Sorry for not letting you know earlier, had to work on other stuff. 

    Thank you again

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard