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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 534

#2
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard