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 / Count the Number of Se...
Power Apps
Answered

Count the Number of Selected Items in a List Box

(1) ShareShare
ReportReport
Posted on by 987

Is it possible to count the number of selected items in a list box?

 

I have tried this but it throws an error:

CountIf(IsEmpty(MultiSelectList.SelectedItems)),"0",MultiSelectList.SelectedItems)

Categories:
  • hpkeong Profile Picture
    2,944 on at

    Hi

     

    CountIf(Table, LogicalFormula)

    - I look at you case, the MultiSelectList,SelectedItems is Not a Condition, so, nothing would be filtered and counter.

     

    Hope I am not out of your question!.

     

    NB:

    BTW, I had replied to another thread on your Q about LookUp couple of days ago. Please check if it helps.

  • audrieFCT Profile Picture
    987 on at

    Thank you for your response.

     

    Wouldn't the IsEmpty be a condition?

     

    Is this closer? (still gives an error message):

    CountIf(ListBoxControlName, ListBoxControlName.SelectedItems<>0)

  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    You can use the CountRows function to get that number:

     

    CountRows(ListBox1.SelectedItems)

  • audrieFCT Profile Picture
    987 on at

    I have just fallen in love with you! (Although I feel kinda dumb to not have thought of them as rows-LOL).

     

    Last question: Do you know how to clear the selection in the list box?

     

    THANK SO VERY MUCH!!

  • hpkeong Profile Picture
    2,944 on at

    Hi

     

    CountRows is right.

    I was looking at your original formula and thought you know CountRows, which is straightforward.

    For CountIf(Table, Condition) .. condition must be set.

     

    Anyway, things are solved. Enjoy!

  • hpkeong Profile Picture
    2,944 on at

    Hi

     

    Select the ListBox, and set Default as context variable, say

    Default = lb

    Meantime, set

    OnHidden = UpdateContext{lb: " "}); UpdateCobtext({lb: ""}) (or set on any button, etc.)

     

    Once you have selected the value in ListBox, and when you navigate away, it will be set to no selection and when you return to the same screen, you will no more selection.

     

    The above UpdateContext can be used with any behaviour formula.

     

    Hope this helps.

  • audrieFCT Profile Picture
    987 on at

    I tried that but it's not clearing the selection. Does it matter that it's a multi-select list box?

  • hpkeong Profile Picture
    2,944 on at

    Hi

     


    @audrieg wrote:

    I tried that but it's not clearing the selection. Does it matter that it's a multi-select list box?


     

    It doesn't matter.

    UpdateContext({xx: " "}); UpdateContext({xx: ""})

    take note of : 1st one: " " (with space in between), 2nd one: "" (no space in between)

     

    FYI: This is used very commonly in PowerApps.

     

    Hope you understand my poor explanation.

     

    Screenshot (214).pngScreenshot (215).png

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 225

#3
M Bilal Khan Profile Picture

M Bilal Khan 192

Last 30 days Overall leaderboard