cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Power Automate Staff audrieg
Power Automate Staff

Count the Number of Selected Items in a List Box

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)

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Count the Number of Selected Items in a List Box

You can use the CountRows function to get that number:

 

CountRows(ListBox1.SelectedItems)

View solution in original post

8 REPLIES 8
hpkeong
Level 10

Re: Count the Number of Selected Items in a List Box

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.

hpkeong
Power Automate Staff audrieg
Power Automate Staff

Re: Count the Number of Selected Items in a List Box

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)

Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Count the Number of Selected Items in a List Box

You can use the CountRows function to get that number:

 

CountRows(ListBox1.SelectedItems)

View solution in original post

Power Automate Staff audrieg
Power Automate Staff

Re: Count the Number of Selected Items in a List Box

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
Level 10

Re: Count the Number of Selected Items in a List Box

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
hpkeong
Level 10

Re: Count the Number of Selected Items in a List Box

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.

hpkeong
Power Automate Staff audrieg
Power Automate Staff

Re: Count the Number of Selected Items in a List Box

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

hpkeong
Level 10

Re: Count the Number of Selected Items in a List Box

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

 

hpkeong

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,760)