cancel
Showing results for
Did you mean:
Helper V

## Counting Multiple Distinct Values in A Gallery and Displaying Totals

Would it be possible to do three things from the data contained within my gallery?

1. Identify distinct "Part Number"(s)

2. Get total "Qty" for each distinct "Part Number"

3. Display the totals in some open space I have on the app page

The goal would be to be able to display this:

Totals

Part Number        Qty

07-21206                2

120189                    2

120674_063             9

433076-8                 12

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User

Ah, I see...formula should be:

``````AddColumns(
GroupBy(yourMainGallery.AllItems,
"Part Number", "_items"
),
"_Qty", Sum(_items, Qty)
)``````
_____________________________________________________________________________________
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!
Helper V

Awesome! Works perfectly. That's a cool formula that I will be able to replicate across some other projects I am working on.

Thank you so much!

5 REPLIES 5
Super User

Create a Gallery in your screen and set the Items property to:

``````AddColumns(
GroupBy(yourMainGallery.AllItems,
"Part Number", "_items"
),
"_Qty", CountRows(_items)
)``````

Add two labels in the gallery and set the first text property to: ThisItem.'Part Number' and the second to: ThisItem._Qty

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

Thank you for the help! We are so close...that code is providing me with a count of how many times each distinct part number is showing up, but I need it to group distinct part numbers together and give the overall qty total.

Here is a screenshot.

The totals should be: 2, 2, 9 and 12.

Super User

Ah, I see...formula should be:

``````AddColumns(
GroupBy(yourMainGallery.AllItems,
"Part Number", "_items"
),
"_Qty", Sum(_items, Qty)
)``````
_____________________________________________________________________________________
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!
Helper V

Awesome! Works perfectly. That's a cool formula that I will be able to replicate across some other projects I am working on.

Thank you so much!

Super User

PowerApps is all about shaping data!  GroupBy is a powerful tool in that toolbox.

Happy to help!

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

Announcements