cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Applications
Helper IV
Helper IV

Get Item Totals From ListBox selection

Hello all!

 

I'm trying to build a PowerApp that will be used for re-ordering items from an inventory, but I'm running into an issue where I can't get the current item amount to show based on a selection from a listbox. Can someone help me out with the formula?

 

Applications_0-1658180125537.png

In the current quantity I want it to show the value I have in the columns "Quantity in Reorder" and "Quantity Overall" in the FFD Inventory SP list:

Applications_1-1658180168022.png

 

So it needs to filter that data source to the listbox selection and provide the sum of the values in those two columns. Any thoughts? 

 

Currently I have

Sum(Filter('FFD Inventory', Sum('Quantity in Reorder' && 'Quantity Overall'), ListBox1.SelectedItemsText.Value))

but it isn't working. 

 

Many thanks! 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Applications 

If your ListBox is set to the datasource items, then you simply need the following:

ListBox1.Selected.'Quantity in Reorder' + ListBox1.Selected.'Quantity Overall')

 

Avoid using the SelectedText property as it is deprecated.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@Applications 

If your ListBox is set to the datasource items, then you simply need the following:

ListBox1.Selected.'Quantity in Reorder' + ListBox1.Selected.'Quantity Overall')

 

Avoid using the SelectedText property as it is deprecated.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

My List box is distinct, here's the formula for the listbox:

Sort(Distinct('FFD Inventory', Description), Ascending)

The reason it's not datasourced is because if I use 'FFD Inventory'.Description' in Items it shows as blank:

Applications_0-1658185219130.png

 

So since it's not a direct datasource, how would your recommendation look via code?

I tried this and it didnt work:

Sum(Filter('FFD Inventory', Sum(ListBox1.Selected.'Quantity in Reorder' + ListBox1.Selected.'Quantity Overall')))

 

Thank you!

RandyHayes
Super User
Super User

@Applications 

Yes, that formula will not work.

 

So my question though is this - if you are doing a distinct (meaning there could be more than one record with the same description), then when you do a sum, which record are you trying to sum??  Or are you trying to sum all of them?

 

If you are trying to sum all of them, then this Formula should give you what you need:

Sum(
    Filter('FFD Inventory', Description=ListBox1.Selected.Result), 
    'Quantity in Reorder' + 'Quantity Overall'
)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Applications
Helper IV
Helper IV

@Randy 

 

Only reason I use distinct is because it showed the results - is there another function I can use rather than Distinct?

 

Also, just trying to sum the columns "Quantity in Stock" and "Quantity in Reorder" from the SharePoint list.

 

Hope this clarifies - thanks!

Applications
Helper IV
Helper IV

Disregard, I was able to get the ListBox to be a direct datasource and then the formula you linked earlier worked. Thank you!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,628)