cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
leandrovegacr
Helper I
Helper I

Sum distinct values grouped by a column

Hi everyone.

 

I have a collection that, for the simplicity of the example, have three columns: Value, Index, Category. Each index has the same value but different categories, and there may be any amount of indexes. What I need is to get the value representing each index, and then, sum all those values. It's important to note each index will always have the same value, this will never change, but different indexes could share a value. What is not possible is for a same index to have different values.

 

So, let's say my collection is:

 

ValueIndexCategory
1001a
1001b
1202c
1003d
1003e

 

So, from this, I need to get 320: 100 representing the index 1, 120 representing the index 2, 100 again representing the index 3.

 

Ideally, This could be calculated without any button pressing, just appending the formula to a text box so it's a value always kept true as the collection is modified.

 

I have been trying with GroupBy and Distinct, but have not get what I need.

 

Thanks for any help!

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@leandrovegacr 

Consider the following formula:

Sum(
    GroupBy(yourList,
        "Index", "Value", "_items"
    ),
    Value
)

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

2 REPLIES 2
RandyHayes
Super User
Super User

@leandrovegacr 

Consider the following formula:

Sum(
    GroupBy(yourList,
        "Index", "Value", "_items"
    ),
    Value
)

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!
leandrovegacr
Helper I
Helper I

It is, definitely, thanks!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,929)