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 / GroupBy AddColumn extr...
Power Apps
Answered

GroupBy AddColumn extremely difficult Calculation using a single collection

(0) ShareShare
ReportReport
Posted on by 34

I have a single collection that tracks the number of hours people and equipment use per job per day 

The columns are like this: 

crew_id     int

crew_type    string  either "EMP" or "EQU" for employee or equipment

job_id      int

tc_date   date

attached_to   int  if  crew_type is "EQU", it must be used by a crew_id that is a "EMP"  Therefore this will have the Emp's crew id

hours  int

 

I'm trying to find out the number of times a crew member's summed hours per job per day  is less hours than the sum of  equipment he is attached to per job per day.

 

 

So, sum up "emp" per job per day and then sum "equ" where that emp is in the attached_to .  Determine emps  have less time that's the equipment they are assigned to.

 

Thanks

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,991 Moderator on at

    @cpolito 

    It would be great if you could provide a sample of the data in the table you are starting with.  Make sure to mention the data type of each column.

     

    Then provide an example of what the result should look like.  It’s the easiest way to communicate the problem in my opinion.

     

    ---
    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."

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @cpolito ,

    Do you want to calculate the sum of hours per job per day, and the the sum of  equipment he is attached to per job per day in a single collection?

     

    Based on the needs that you mentioned, I think single one collection could achieve your needs. Please consider take a try with the following workaround (set the OnSelect property of a button to following formula) :

    ClearColelct(
     FinalResult,
     AddColumns(
     RenameColumns(
     GroupBy(
     Filter(
     'Original Table',
     crew_type = "EMP"
     ),
     "job_id",
     "tc_date",
     "crew_id",
     "GroupData"
     ),
     "crew_id", "EMP_ID",
     "job_id", "JOB_ID",
     "tc_date", "Work_Date"
     ),
     "TotalHour_EMP",
     Sum(GroupData, hours),
     "TotalHour_EQU",
     Sum(
     Filter(
     'Original Table', 
     crew_type = "EQU", 
     attached_to = EMP_ID,
     job_id = JOB_ID,
     tc_date = Work_Date
     ),
     hours
     )
     )
    )

    Please consider take a try with above solution, then TotalHour_Emp and TotalHour_EQU for each emp per job per day would be stored into the FinalResult collection.

     

    You could then add a Data Table control in your app, set the Items property to the FinalResult collection, then enable desired fields (e.g. TotalHour_Emp, TotalHour_EQU, EMP_ID, ....) in this Data Table, then you could check TotalHour_Emp and TotalHour_EQU value for each emp per job per day in that Data Table.

     

    Please take a try with above solution, check if the issue is solved.

     

    Best regards,

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
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard