Skip to main content
Community site session details

Community site session details

Session Id : nAaBSh8x+IqY5lrufnhjnS
Power Apps - Building Power Apps
Unanswered

Sum the quantities in a column by distinct

Like (0) ShareShare
ReportReport
Posted on 17 May 2018 23:36:10 by 10

I have a TableA


Name    Quantity

Ben            6

Andy          3

Ben           4

John          6

George      2

Andy         5

 

I use ClearCollect ( Col_stats, RenameColumns( Distinct (TableA, Name),"Result","Name")  to create Col_stats.

 

I want Col_Stats to show the following

 

Name       Count         Sum          Avg

Andy            2               8               4

Ben              2               10            5   

John             1               6              6

George        1                2              2

 

 

 

How would I do this?

 

 

Now I need to maybe use the ForAll function that will evaluate across table A, using the distinct records of Table B.   

 

I know I need to use AddColumns to create a new column in the collection.  Having trouble wrapping my head around how to structure this.

Categories:
  • BrendanZ1 Profile Picture
    333 on 20 May 2020 at 06:54:26
    Re: Sum the quantities in a column by distinct

    I am adding to this older thread as I have used the solution provided by @CMee in order for me to create a collection that calculates my total stock on hand per BatchCode.

     

    So I have in a gallery a column for BatchCode and Tsum

    ClearCollect(Col_stats,
    	AddColumns(GroupBy('Stock Receivals',"BatchCode","Total"),
    		"TSum",Sum(Total.SOH,SOH)
    	)
    )

     

    What I don't know how to do, is bring in additional fields from my SP List so that in the gallery, I can identify the product by name and barcode, not just BatchCode. How would I include these fields?


    Thanks

  • Community Power Platform Member Profile Picture
    on 23 Jan 2020 at 16:27:31
    Re: Sum the quantities in a column by distinct

    Thanks @CMee , this worked for me. Had to remove a column that contained records from the view, but is displaying the correct information.

  • CMee Profile Picture
    72 on 18 May 2018 at 01:15:46
    Re: Sum the quantities in a column by distinct

    I've never used AddColumns before, but anyway, see if this works:

     

     

    ClearCollect(Col_stats,
    	AddColumns(GroupBy(TableA,"Name","NameGroup"),
    		"TSum",Sum(NameGroup.Quantity,Quantity),
    		"TCount",CountA(NameGroup.Quantity),
    		"TAverage",Average(NameGroup.Quantity,Quantity)
    	)
    )

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete