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 / Setting a variable to ...
Power Apps
Unanswered

Setting a variable to count the number of records that meet a criteria

(0) ShareShare
ReportReport
Posted on by

I am wanting to set a variable (trncount) that counts the number of records that have a particular text the same as that in my dropdown box. Can you help me with the syntax? It keeps telling me that I am trying to compare a table to a record.

 

Set(trncount,CountIf(Training, Training.Description = Dropdown4.SelectedText))

 

Any help much appreciated

 

Peter 

Categories:
I have the same question (0)
  • shoog Profile Picture
    2,164 on at

    You should remove the table name in the second parameter like this:

    Set(trncount,CountIf(Training, Description = Dropdown4.SelectedText))
  • peter5164 Profile Picture
    on at

    No, it still comes up with the same error. I actually had it that way before and changed it trying to fix it. But I worked it out. It seems I needed to create a collection (colTrain) and apply the formula to that,

     

    ClearCollect(colTrain,Training);Set(trncount,CountIf(colTrain, Description = Dropdown4.SelectedText.Value))
    

    Thanks for your help

     

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

#2
Haque Profile Picture

Haque 230

#3
Kalathiya Profile Picture

Kalathiya 217 Super User 2026 Season 1

Last 30 days Overall leaderboard