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 / Why does variable usin...
Power Apps
Answered

Why does variable using countrow return wrong value?

(0) ShareShare
ReportReport
Posted on by 19

I have a collection of 3 items. Consider the following code:

 

 

 

Set( varAmount, CountRows(collection));
Notify(Text(varAmount) & " --- " & Text(CountRows(collection)));

 

 

 

For some reason, this is the output:

 

 

2 --- 3

 

 

 

How come these are not exactly the same value, when used like this?

Categories:
I have the same question (0)
  • BCLS776 Profile Picture
    8,994 Moderator on at

    Your code works properly when I test it in my environment. A list with 12 items returns:

    12 --- 12

    Have you tried it on other data sources to see if the incorrect behavior shows? If so, I suggest starting a support ticket with Microsoft.

     

    Bryan

  • Verified answer
    PresidentWillem Profile Picture
    19 on at

    I have figured out the solution. It turns out I had another local variable with the same name, causing the smaller scope to win (this var was set at 2). The solution in my case was to eliminate/rename the local var.

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 846

#2
Valantis Profile Picture

Valantis 532

#3
Haque Profile Picture

Haque 410

Last 30 days Overall leaderboard