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

GroupBy AddColumn extremely difficult Calculation using a single collection

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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: GroupBy AddColumn extremely difficult Calculation using a single collection

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Highlighted
Super User
Super User

Re: GroupBy AddColumn extremely difficult Calculation using a single collection

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

Highlighted
Community Support
Community Support

Re: GroupBy AddColumn extremely difficult Calculation using a single collection

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,605)