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 Count(singleColumn...
Power Apps
Answered

Why Count(singleColumnTable) = CountA(singleColumnTable)?

(0) ShareShare
ReportReport
Posted on by 28

Hi,

 

I have a collection named CntTest.

 

 

Set( CntTest,
 [1, "ax", Blank(), "", 3, "45"]
);

 

 

and

 

 

Count(CntTest) & "-" & CountA(CntTest)

 

 

It outputs 3-3.

 

According to the MS doc,

The Count function counts the number of records that contain a number in a single-column table.

The CountA function counts the number of records that aren't blank in a single-column table. This function includes empty text ("") in the count.

I think the result will be 2-5, at least it should be 3-5.

Count anybody explain why it outputs 3-3?

 

Thank you very much!

 

- sukie

Categories:
I have the same question (0)
  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @sukie,

    According to our doc:

    1. the Count() function counts the number of records that contain a number.
    2. the CountA() function counts the number of records that aren't blank but including the empty text "" in the count.

    However, both of these 2 functions only support a unified data type column which is not the scenario that you have done with.

    The variable you created seems to be a column table including Text and Number values, but seeing is not always believing. The data type is automatically transferred to Number based on the first item in your variable.

    In your scenario, the first item is a number value 1, so the data type of the left items is changed into Number type at the same time.

    In a word, the variable you created is changed into a number column including only three numbers 1, 3, 45, that explains why the Count() and CountA() always return 3.

    Hope it could help.

  • sukie Profile Picture
    28 on at

    Hi @v-qiaqi-msft ,

     

    Thank you for your explain !

     

    But there is one more question that if I use

    Count(CntTest) & "-" & CountA(CntTest) & "-" & CountRows(CntTest)

    I got 3-3-6.

    So, the CntTest is not converted directly to [1, 3, 45], is that something like Pass By Value of method parameter in Java? I mean if the CntTest remains same as it declared,  and in the countXXX method, it is cast  to [1, 3, 45] ?

     

    Best Regards.

     

    - sukie

     

     

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @sukie,

    "The variable you created is changed into a number column including only three numbers 1, 3, 45."

    I mean a column including three numbers but with another 3 blank rows, which means that you will get a column including 6 rows but only has 3 number values. That's why the CountRows() returns 6.

    vqiaqimsft_0-1629789457417.png

    The formula you used will create a variable with 6 rows but only including 3 valid number values.

    Hope this could explain what makes you confused.

  • sukie Profile Picture
    28 on at

    Hi @v-qiaqi-msft ,

     

    Thank you very much!!

    Now I understand the mechanism.

    It's very kind of you. 🙂

     

    Best Regards,

     

    - sukie

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 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard