web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Problem add sum column
Power Apps
Answered

Problem add sum column

(0) ShareShare
ReportReport
Posted on by 137

Hi,

Thanks for all help ,i have a Collection with User;Program and Hours, and something like that:

 

Collect1:

User1 Program1 3h

User2 Program1 4

User1 Program1 2

User3 Program2 2

User2 Program2 2

User2 Program2 4

 

I would like to create another Collection ,grouped by User/Program and Hours that has

 

Collect2:

User1 Program1 5 (3+2)

User2 Program1 4

User3 Program2 2

User2 Program2 6 (4+2)

 

But have been impossible to me to create it....

 

At this moment I have only this:

 

 Collect(
        Collect1;
        {
            Usuario: lista_software_horas_programa[@usuario];
            Programa: lista_software_horas_programa[@Programa];
            Horas: lista_software_horas_programa[@horas]
        }
    )
;;
ClearCollect(Collect2;
GroupBy(Collect1; "Usuario"; "Programa" )
);;
 
With this i have a Collect2, with User and a table with their programs and hours, but its not what i want...
 
Any help will be very apreciated.
 
Thanks
 
Categories:
  • Verified answer
    mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at

    hey @llserra 

     

    can you please try this:

    ClearCollect(Collect2,
     AddColumns(
     GroupBy(Collect1, "User", "Program", "GroupedData"),
     "TotalHours", Sum(GroupedData, Hours)
     )
    );
    
    

    In this formula:

    GroupBy(Collect1, "User", "Program", "GroupedData") groups your original collection by User and Program. The result is a collection of unique User/Program combinations, each with a sub-collection (GroupedData) of the original items that fall into that group.

     

    AddColumns(..., "TotalHours", Sum(GroupedData, Hours)) adds a new column to each group record that contains the sum of Hours from the GroupedData of that record.

    This approach will give you a new collection (Collect2) where each record is a unique combination of User and Program, with an additional field (TotalHours) representing the total hours spent by that user on that program.

    Please replace the Hours in the Sum(GroupedData, Hours) part of the formula with the correct name of your hours field if it's different. This solution assumes that Hours is the correct field name in your Collect1 collection.

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • llserra Profile Picture
    137 on at

    Thanks!!! It works!

    With my code:

     

    ClearCollect(
        lista_software_horas_programa_limpia_sum_horas;
        AddColumns(
            GroupBy(
                lista_software_horas_programa_limpia;
                "Usuario";
                "Programa";
                "Grupo"
            );
            "TotalHoras";
            Sum(
                Grupo;
                Horas
            )
        )
    );;
    ClearCollect(
        lista_software_horas_programa_limpia_sum_horas_2;
        DropColumns(
            lista_software_horas_programa_limpia_sum_horas;
            "Grupo"
        )
    );;
    Thanks again for all

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard