Help, merging data rows with unique values.

SiEn

New Member
Joined
Mar 28, 2023
Messages
22
Office Version
  1. 365
Platform
  1. Windows
Good Morning All,

I am after some help please, I have created multiple spreadsheets to automate some workers hours on site..
I have various sheets using power query to obtain the final information unfortunately due to the way the data is written it contains some duplicated (of sorts) lines and i would really like to be able to merge this data.. I have taken a small snippet from my sheet which hopefully shows the issue i have..

Basically any row of data that has the same worker name and job number (first 2 columns) i would like to be combined into 1 row (this could be more than 2 rows), they will have data that is unique to that row (hrs worked) that also need to be combined or summed together..

(i.e in the snippet below the 2 lines would become one with the hours on 1 line and any that requiring summing together would be..)

1700997140307.png


Is this possible? is it easy?
Any help appreciated..
Many Thanks Simon
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Cannot manipulate data in a picture. If you can, repost some data (8-10) records using XL2BB. I believe that this can be resolved using PQ and using the Group By function to sum the various columns.
 
Upvote 0
Book1.xlsx
ABCDEFGHIJKLMNOPQRST
1Worker NameJob NumberEmployerTradeBasic (Mon)OT A (Mon)OT Single (Mon)Nights (Mon)OT Nights (Mon)Sick (Mon)Unpaid (Mon)Holiday (Mon)Basic (Tue)OTA (Tue)OT Single (Tue)Nights (Tue)OT Nights (Tue)Sick (Tue)Unpaid (Tue)Holiday (Tue)
2Worker 11234567.52.53.75
3Worker 11234563.75
4Worker 22345677.55
5Worker 22345672.5
6Worker 33456787.517
7Worker 33456781.50.5
8Worker 445678942.57.51.5
9Worker 44567893.51
Sheet1
 
Upvote 0
With Power Query, 1--Unpivot your data and then re-pivot it to summarize

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Worker Name", "Job Number", "Employer", "Trade"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Attribute]), "Attribute", "Value", List.Sum)
in
    #"Pivoted Column"

Worker NameJob NumberEmployerTradeBasic (Mon)OT A (Mon)Basic (Tue)Nights (Mon)OT Nights (Mon)Nights (Tue)OT Nights (Tue)
Worker 11234567.52.57.5
Worker 22345677.57.5
Worker 33456787.52.57.5
Worker 44567897.52.57.52.5
 
Upvote 0
Solution
wow that's great is it possible to return all the original columns incl blanks?
 
Upvote 0
That will take a different approach. Using Power Query, Group By the first four columns and then sum each of the remaining columns. I will do this for the first three and you can then see how and be able to do for all columns.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Grouped Rows" = Table.Group(Source, {"Worker Name", "Job Number", "Employer", "Trade"}, {{"Total Basic (Mon)", each List.Sum([#"Basic (Mon)"]), type nullable number}, {"Total OTA (Mon)", each List.Sum([#"OT A (Mon)"]), type nullable number}, {"Total OT Single (Mon)", each List.Sum([#"OT Single (Mon)"]), type any}})
in
    #"Grouped Rows"
 
Upvote 0

Forum statistics

Threads
1,215,068
Messages
6,122,950
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top