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 / Help with ClearCollect...
Power Apps
Answered

Help with ClearCollect() and Filter()

(0) ShareShare
ReportReport
Posted on by
Hello, I have a SharePoint list that I am using as a Data Source in my Power App. It has a text column in it called "Team".
I am trying to create a collection to then use in a pie chart using the following code:
 
ClearCollect(
    TeamCollection,
    ForAll(
        ["Safety & Security", "Control & Software", "Engineering Management", "Electrical & Electronics", "Systems"],  // List of team names
        {
            Team: ThisRecord,  // Current team name
            Count: CountRows(
                Filter(
                    'Form Answers',
                    Team = ThisRecord  // Compare the text column's value
                )
            )
        }
    )
);
I get the error: Incompatible types for comparison. These types can't be compared: Text, Record.
 
The error shows on the "=" on line 10.

I have tried adding ".Value" onto the end of ThisRecord which gives me a name not found error.
 
Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,781 Most Valuable Professional on at
    Try this
    ClearCollect(
       TeamCollection,
       ForAll(
          ["Safety & Security", "Control & Software", "Engineering Management", "Electrical & Electronics", "Systems"],
          {
             Team: Value,
             Count: 
             CountRows(
                Filter(
                   'Form Answers',
                   Team = Value
                )
             )
          }
       )
    );
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    Buy me a coffee

  • Suggested answer
    Rayon Robert Profile Picture
    20 on at
     
    I tried re-creating the your inputs for the required output.
    Below is the snip of the 'Form Answers' where I have 'Control Software' value containing 2 entries (for instance).
     
    In order to collect per your requirement, I have updated the below code where the Value from your 'Form Answers' are used to calculate the count.
     
    ClearCollect(
        TeamCollection,
        ForAll(
            ["Safety & Security", "Control & Software", "Engineering Management", "Electrical & Electronics", "Systems"], // List of team names
            {
                Team: Value, // Current team name
                Count: CountRows(
                    Filter(
                        colFormAnswers,
                        Team = Value // Compare the "Team" column's value in the data source
                    )
                )
            }
        )
    );
     

    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
     
  • Suggested answer
    SaiRT14 Profile Picture
    1,990 Super User 2025 Season 1 on at
    Error because ThisRecord in the ForAll loop is a record, not text.
     
    here is the corrected code, pls try:
    ClearCollect(
        TeamCollection,
        ForAll(
            ["Safety & Security", "Control & Software", "Engineering Management", "Electrical & Electronics", "Systems"],  // List of team names
            {
                Team: ThisRecord,  // Current team name
                Count: CountRows(
                    Filter(
                        'Form Answers',
                        Team = ThisRecord.Value  // Use ThisRecord.Value to get the actual text value
                    )
                )
            }
        )
    );
     
  • WarrenBelz Profile Picture
    153,781 Most Valuable Professional on at
    Please have a look at my post at the bottom- I have tested it and it works. 
  • WarrenBelz Profile Picture
    153,781 Most Valuable Professional on at
    A quick follow-up to see if you received the answer you were looking for or if you need further assistance.

    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps   

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 93 Most Valuable Professional

#2
Haque Profile Picture

Haque 81

#3
Valantis Profile Picture

Valantis 49

Last 30 days Overall leaderboard