cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
powerapps-dev
Level: Powered On

PowerApps ListBox/ ComboBox only selecting last selected rather than all.

Hi,

 

I am creating an App where multiple selections from ListBox/ ComboBox need to be carried over to another control. Only the last selected item is being reflected in other control. I have tried many combinations with both Select.Value, SelectedItems.Value, use of different controls... Just anything you could think of. 

I have not been able to find a solution in existing posts and have tried use of a collection and the ForAll function, nothing.

 

I have used a ListBox in example shown, but I am having the same issue with both ListBox and ComboBox, have tried using a mixture and both seperately.

They are connected to an Excel data source.

Countries and Weightings.pngFirst ListBox displays list of Countries, 2nd ListBox displays it's associated weighting

Formula used for 1st ListBox Items: 

Distinct(CountryWeighting,'Country w')

Formula used for 2nd ListBox Items: 

Filter(CountryWeighting,'Country w'=ListBox1.Selected.Result)

 

For 2nd ListBox when I tried using

Filter(CountryWeighting,'Country w'=ListBox1.SelectedItems)

&

Filter(CountryWeighting,'Country w'=ListBox1.SelectedItems.Result)

I get an error message stating "Invalid argument type" for both.

 

 

Selected1.pngSelected2.pngSelected3.pngThese three images shows me making multiple selections on ListBox to the left (Angola, Australia and Azerbaijan). Multiple select is enabled on all ListBoxes used. Yet only the last selected result is reflected 

Another quick example to further demonstrate this issue...

2ndExample.pngFor the the Text input on the right labelled 1, the formula on Default is If(ListBox1_1.Selected.Value="Angola", "1") and for the Text input labelled 2, the formula on default is If(ListBox1_1.Selected.Value="Australia", "1"). Instead of all selected results being reflected, only the last selected result is reflected. Same as before, I tried replacing the Selected.Value of formula with SelectedItems and SelectedItems.Value, but to no avail, both return error messages same as before- 'Invalid Argument type' .

 

I have tried fiddling around with using ForAll in the formula but cannot seem to get it working, and also tried using a collect to capture results, but collect does not update properly when items are unselected and selected.

 

Collection.pngFormula used on ListBox OnSelect for collection- Collect(CBCountries, {CBCS: ListBox1_1.SelectedItems}). This purple symbol appears on ListBox. Have to press on the symbol to open and then it displays as normal. But Collection not updating normally with SelectedItems from ListBox, the values displayed in the Collection do not correlate to what I have selected in ListBox.

 

I have tried using PowerApps Data table and filtering that out according to listbox selected and galleries same thing. But the annoying issue of last selected is consistent through all approaches.

 

I have no clue where I am going wrong, what to do next or if there is some kind of issue with PowerApps mulitple selection in controls.

 

 

Looking forwarded to help and suggestions!!

Thank you.

2 ACCEPTED SOLUTIONS

Accepted Solutions
powerapps-dev
Level: Powered On

PowerApps sum ListBox items

Hi,

 

I have found a solution to this.

 

I was filtering the table from excel to show specified columns instead (on ListBox; items using Distinct(CountryWeighting,'Country w') for the first ListBox and Filter(CountryWeighting,'Country w'=ListBox1.Selected.Result) for the second ListBox) but in powerapps you can edit the controls in advanced settings to show certain columns instead. So something in the distnct/filter formula wouldn't allow select multiple. Now on first ListBox I simply have the name of the excel table CountryWeighting and on the ListBox to the right on items I have ListBox1.Selected Items.

 

 

Current Problem as follows....

 

I have a list of numbers being populated into a listbox (from another list box). I would like to be able to sum all the numbers/ items in the listbox. 

 

Next.pngListBox to the right connected to an excel data source reflecting a country list. ListBox to the right is the associated weightings for the selected countries of ListBox to the right.

 

Formula on Items for ListBox to the left:

CountryWeighting (Name of excel table data source)

Formula on Items for Listbox to the right:

ListBox1.SelectedItems

 

For the Text input below, on Default, I would like to sum all of the weightings/ numbers in the ListBox to the right.

I have tried different filter combinations e.g.

Sum(Filter(CountryWeighting, Weight=ListBox1.SelectedItems), Weight)

This returns an error message stating 'Invalid argument type'. I have also changed the Text input format to Number, still no result.

Sum(CountryWeighting, Weight), sums all the weightings in excel rather than those I have selected in App.

I got 

I got Sum(Filter(CountryWeighting, Weight=ListBox1.Selected.Weight), Weight) to work, but the value it is returning are incorrect and it's only returning the last selected item in the listbox rather than adding all value.

 

 

Is this the correct approach to take? Are there alternative methods?

 

All help appreciated,

Best Regards

 

View solution in original post

powerapps-dev
Level: Powered On

Re: PowerApps sum ListBox items

Solved,

 

Using formula:

Sum(ListBox2.SelectedItems, Weight) 

On Text input default

View solution in original post

2 REPLIES 2
powerapps-dev
Level: Powered On

PowerApps sum ListBox items

Hi,

 

I have found a solution to this.

 

I was filtering the table from excel to show specified columns instead (on ListBox; items using Distinct(CountryWeighting,'Country w') for the first ListBox and Filter(CountryWeighting,'Country w'=ListBox1.Selected.Result) for the second ListBox) but in powerapps you can edit the controls in advanced settings to show certain columns instead. So something in the distnct/filter formula wouldn't allow select multiple. Now on first ListBox I simply have the name of the excel table CountryWeighting and on the ListBox to the right on items I have ListBox1.Selected Items.

 

 

Current Problem as follows....

 

I have a list of numbers being populated into a listbox (from another list box). I would like to be able to sum all the numbers/ items in the listbox. 

 

Next.pngListBox to the right connected to an excel data source reflecting a country list. ListBox to the right is the associated weightings for the selected countries of ListBox to the right.

 

Formula on Items for ListBox to the left:

CountryWeighting (Name of excel table data source)

Formula on Items for Listbox to the right:

ListBox1.SelectedItems

 

For the Text input below, on Default, I would like to sum all of the weightings/ numbers in the ListBox to the right.

I have tried different filter combinations e.g.

Sum(Filter(CountryWeighting, Weight=ListBox1.SelectedItems), Weight)

This returns an error message stating 'Invalid argument type'. I have also changed the Text input format to Number, still no result.

Sum(CountryWeighting, Weight), sums all the weightings in excel rather than those I have selected in App.

I got 

I got Sum(Filter(CountryWeighting, Weight=ListBox1.Selected.Weight), Weight) to work, but the value it is returning are incorrect and it's only returning the last selected item in the listbox rather than adding all value.

 

 

Is this the correct approach to take? Are there alternative methods?

 

All help appreciated,

Best Regards

 

View solution in original post

powerapps-dev
Level: Powered On

Re: PowerApps sum ListBox items

Solved,

 

Using formula:

Sum(ListBox2.SelectedItems, Weight) 

On Text input default

View solution in original post

Helpful resources

Announcements
thirdimage

Power Platform 24

Check it out!

thirdimage

New Badges

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

Top Solution Authors
Top Kudoed Authors
Users online (4,752)