cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Field
Helper V
Helper V

Distinct and sum 2 columns

Hello, 

 

In my sharepoint list i have the following items:

 

Title - Number

 

Test A - 4

Test A - 2

Test A - 2

Test B - 3

Test C - 2

Test B - 3

 

I want to put that information in a gallery but remove duplicates and add them together, so in reality, the gallery on PowerApps should be showing this:

 

Test A - 8

Test B - 6

Test C - 2

 

I can remove duplicates, but not sum.

Using sum will give a random number that i do not want

 

Can somebody help?

 

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User III
Super User III

@Field 

This is a classic Collections problem called "How can I GROUPBY a column and SUM the values".  Here's the solution

 

ClearCollect(
    myGroupedCollection,
    GroupBy(your_datasource_name,"Title","GroupedItems")
);

ClearCollect(
    mySolution,
    DropColumns(
        AddColumns(myGroupedExpenses,"Sum of Value",Sum(GroupedItems,Value)),
        "GroupedItems"
    )
);

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

1 REPLY 1
mdevaney
Super User III
Super User III

@Field 

This is a classic Collections problem called "How can I GROUPBY a column and SUM the values".  Here's the solution

 

ClearCollect(
    myGroupedCollection,
    GroupBy(your_datasource_name,"Title","GroupedItems")
);

ClearCollect(
    mySolution,
    DropColumns(
        AddColumns(myGroupedExpenses,"Sum of Value",Sum(GroupedItems,Value)),
        "GroupedItems"
    )
);

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (71,181)