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

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
Power Apps

You can use the CountRows function to get that number:

 

CountRows(ListBox1.SelectedItems)

View solution in original post

8 REPLIES 8
Community Champion
Community Champion

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

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
Power Apps

You can use the CountRows function to get that number:

 

CountRows(ListBox1.SelectedItems)

View solution in original post

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!!

Community Champion
Community Champion

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
Community Champion
Community Champion

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

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

Community Champion
Community Champion

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
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (7,224)