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 / Is it possible in Powe...
Power Apps
Unanswered

Is it possible in Power App Gallery Items using Filter but also needing to count rows using ID from Items, but count rows from another child SharePoint list?

(0) ShareShare
ReportReport
Posted on by 24

Is it possible in Power App Gallery Items using Filter but also needing to count rows using ID from Items, but count rows from another child SharePoint list?

 

I am currently gathering Items for a Gallery using SortByColumns and Filter based on some drop downs or a search field as follows:

SortByColumns
(
    Filter
    (
        [@'Vendors'],
        SearchTextInput.Text in 'Vendor Name'
        && If(ddVendorStatus.SelectedText.Value = "All", 'Vendor Status'.Value = "Active" || 'Vendor Status'.Value = "Not Used Anymore" || 'Vendor Status'.Value = "Winding Down",
            If(ddVendorStatus.SelectedText.Value = "Active", 'Vendor Status'.Value = "Active",
            If(ddVendorStatus.SelectedText.Value = "Not Used Anymore", 'Vendor Status'.Value = "Not Used Anymore", 'Vendor Status'.Value = "Winding Down")))
        && If(ddVendorCountry.SelectedText.Value = "All", true, 'Vendor Country' = ddVendorCountry.SelectedText.Value)
    ),
    "Title", SortOrder.Ascending
)
 
In a Text field in the gallery I am doing a CountRows that uses ThisItem.ID to count the rows in a child SharePoint List of the Vendors as follows:

CountRows(
    Filter
    (
        [@'Vendor Surveys'],          
        'Consulting Vendor:ID'.Value = ThisItem.ID
    )
)
 
Is there a way possible where I can load the value of the CountRows in the initial gallery Items method? So something like this - where I filter on ddSurveyCount either by All, Zero or > Zero? 
 
SortByColumns
(
    Filter
    (
        [@'Vendors'],
        SearchTextInput.Text in 'Vendor Name'
        && If(ddVendorStatus.SelectedText.Value = "All", 'Vendor Status'.Value = "Active" || 'Vendor Status'.Value = "Not Used Anymore" || 'Vendor Status'.Value = "Winding Down",
            If(ddVendorStatus.SelectedText.Value = "Active", 'Vendor Status'.Value = "Active",
            If(ddVendorStatus.SelectedText.Value = "Not Used Anymore", 'Vendor Status'.Value = "Not Used Anymore", 'Vendor Status'.Value = "Winding Down")))
        && If(ddVendorCountry.SelectedText.Value = "All", true, 'Vendor Country' = ddVendorCountry.SelectedText.Value)
        && If(ddSurveyCount.SelectedText.Value = "All", true,
            CountRows(Filter([@'Consulting Vendors Management Survey'],'Consulting Vendor:ID'.Value = ThisItem.ID)) > 0)
    ),
    "Title", SortOrder.Ascending
)
 
I get a failure because the ThisItem.ID does not exist at this time in the Items method.
Is this even possible to this type of Lookup or CountRows from with the Items method? Or is this something I am going to have to create a Collection and then use that Collection in the Items Method?
Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,960 Moderator on at

    @JWolmanSymplr 

     

    I am confused. If you have a Label in the gallery, doing CountRows there should work no problem.

     

    Why do you want to add it to the Items/Filter instead of the Text Box?

     

    Essentially not exactly, you could do some extremely unnecessary things to do what you are asking in items, but what is wrong with your CountRows?


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • JWolmanSymplr Profile Picture
    24 on at

    Sorry I was on vacation for a bit, but my problem is that in the method where I am gathering data using the SortColumns(Filter logic I cannot use ThisItem.Id to get the count of rows for each item. Like I can do that in a separate text box because it's not in the Gallery method.

     

    So I am trying to load a collection of objects from one SharePoint list, but for each record in that collection I want to use a field (i.e. ID) to get a count of records from another SharePoint list. And I know only how to use ThisItem.ID

  • Sam_Fawzi Profile Picture
    868 Super User 2026 Season 1 on at

    Step-by-Step Guide

    1. Create a Collection for Vendors: First, create a collection that holds your vendor data with an additional field for the count of related survey items.

    2. Calculate the Count for Each Vendor: Use the ForAll function to iterate through your vendor list and calculate the count of related survey items.

    3. Use the Collection in Your Gallery: Finally, use the created collection as the Items property of your gallery and apply the necessary filters and sorts.

     

    ClearCollect(
     VendorCollection,
     AddColumns(
     [@'Vendors'],
     "SurveyCount",
     CountRows(
     Filter(
     [@'Vendor Surveys'],
     'Consulting Vendor:ID'.Value = ID
     )
     )
     )
    );

     

     

    Filter and Sort the Gallery Items: Use the created VendorCollection and apply your filter and sort logic.

     

    SortByColumns(
     Filter(
     VendorCollection,
     SearchTextInput.Text in 'Vendor Name'
     && If(
     ddVendorStatus.SelectedText.Value = "All",
     'Vendor Status'.Value in ["Active", "Not Used Anymore", "Winding Down"],
     'Vendor Status'.Value = ddVendorStatus.SelectedText.Value
     )
     && If(
     ddVendorCountry.SelectedText.Value = "All",
     true,
     'Vendor Country' = ddVendorCountry.SelectedText.Value
     )
     && If(
     ddSurveyCount.SelectedText.Value = "All",
     true,
     ddSurveyCount.SelectedText.Value = "Zero" && SurveyCount = 0 ||
     ddSurveyCount.SelectedText.Value = "> Zero" && SurveyCount > 0
     )
     ),
     "Title",
     SortOrder.Ascending
    )

     

     

     

    Explanation

    • ClearCollect: Creates or clears a collection (VendorCollection) and adds new records.
    • AddColumns: Adds a calculated column (SurveyCount) to the vendors' data, where the count of related survey items is calculated using CountRows.

    If my assistance has been helpful, I would greatly appreciate it if you could mark my answer as Resolved/Answered and give it a thumbs up. This helps others benefit from the solution as well.

    Thank you!

     

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard