Combining rows with multiple transactions on same dates

tigerzen

Board Regular
Joined
Mar 8, 2023
Messages
165
Office Version
  1. 365
Platform
  1. Windows
The spreadsheet illustrates what is needed, easy enough to do when the dates are different but need to be able to consolidate by date. The desired output is in Columns C and D. The user does not have Excel 365 and is using Excel 2016. I'm after a formula solution, helper columns are ok if no other solution exists. Power query/VBA solutions will do if the formulaic solution is not practical.
Book5
ABCDE
1DateDescriptionDateDescription
21/01/2023Room A hired 3 hours1/01/2023Room A hired 3 hours, Room B hired 2 hours
3Room B hired 2 hours2/01/2023Room C hired 1 hour, Materials usage low, Room A hired 1 hour, Room E hired 1 hour, Room D hired 2 hours
42/01/2023Room C hired 1 hour4/01/2023Room A hired 3 hours etc
5Materials usage low
62/01/2023Room A hired 1 hour
7Room E hired 1 hour
8Room D hired 2 hours
94/01/2023Room A hired 3 hours
10Room B hired 2 hours
11Materials required
12Order required
Sheet2
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type datetime}, {"Description", type text}}),
    #"Filled Down" = Table.FillDown(#"Changed Type",{"Date"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Filled Down",{{"Date", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type1", {"Date"}, {{"Description", each Text.Combine([Description], ", "), type text}})
in
    #"Grouped Rows"
 
Upvote 0
.. using Excel 2016. I'm after a formula solution, helper columns are ok ..
See if this would suit. I have used G & H as helper columns.

23 05 06.xlsm
ABCDEFGH
1DateDescription
21/01/2023Room A hired 3 hours1/01/2023Room A hired 3 hours, Room B hired 2 hours1/01/2023Room A hired 3 hours
3Room B hired 2 hours2/01/2023Room C hired 1 hour, Materials usage low, Room A hired 1 hour, Room E hired 1 hour, Room D hired 2 hours, Other 1, Other 21/01/2023Room A hired 3 hours, Room B hired 2 hours
42/01/2023Room C hired 1 hour4/01/2023Room A hired 3 hours, Room B hired 2 hours, Materials required, Order required2/01/2023Room C hired 1 hour
5Materials usage low  2/01/2023Room C hired 1 hour, Materials usage low
62/01/2023Room A hired 1 hour  2/01/2023Room C hired 1 hour, Materials usage low, Room A hired 1 hour
7Room E hired 1 hour2/01/2023Room C hired 1 hour, Materials usage low, Room A hired 1 hour, Room E hired 1 hour
8Room D hired 2 hours2/01/2023Room C hired 1 hour, Materials usage low, Room A hired 1 hour, Room E hired 1 hour, Room D hired 2 hours
94/01/2023Room A hired 3 hours4/01/2023Room A hired 3 hours
10Room B hired 2 hours4/01/2023Room A hired 3 hours, Room B hired 2 hours
11Materials required4/01/2023Room A hired 3 hours, Room B hired 2 hours, Materials required
12Order required4/01/2023Room A hired 3 hours, Room B hired 2 hours, Materials required, Order required
132/01/2023Other 12/01/2023Room C hired 1 hour, Materials usage low, Room A hired 1 hour, Room E hired 1 hour, Room D hired 2 hours, Other 1
14Other 22/01/2023Room C hired 1 hour, Materials usage low, Room A hired 1 hour, Room E hired 1 hour, Room D hired 2 hours, Other 1, Other 2
Combine
Cell Formulas
RangeFormula
D2:D6D2=IFERROR(AGGREGATE(15,6,G$2:G$14/ISNA(MATCH(G$2:G$14,D$1:D1,0)),1),"")
E2:E6E2=IF(D2="","",INDEX(H:H,AGGREGATE(14,6,ROW(H$2:H$14)/(G$2:G$14=D2),1)))
G2:G14G2=IF(A2="",G1,A2)
H2:H14H2=IF(A2="",H1&", "&B2,IFERROR(INDEX(H$1:H1,AGGREGATE(14,6,ROW(H$1:H1)/(G$1:G1=A2),1))&", ","")&B2)
 
Upvote 0
Thanks Sanjeev and Peter, both solutions work fine. I've looked at the original data and feel that the users of the data would benefit by noting the instances of hiring. So as a follow up question to my original post what would we have to change in the solution to get a summary of what occurs each transaction, the desired output would be the same for both 1/01/2023 and the 4/01/2023 as there was only one transaction on those days, the complication would be for the 2/01/2023 and should be separately notated so that we get:
2/01/2023 Room C hired 1 hour, Materials usage low
2/01/2023 Room A hired 1 hour, Room E hired 1 hour, Room D hired 2 hours

I imagine this might be easier than the original question formula wise?
 
Upvote 0
Try this

Cell Formulas
RangeFormula
D2:D8D2=IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW(A$2:A$14)/(A$2:A$14<>""),ROWS(D$2:D2))),"")
E2:E8E2=IF(D2="","",INDEX(G:G,AGGREGATE(15,6,ROW(G$2:G$14)/(A$2:A$14=D2),COUNTIF(D$2:D2,D2))))
G2:G14G2=IF(A2<>"",B2&IF(AND(A3="",B3<>""),", "&G3,""),B2&IF(AND(A3="",B3<>""),", "&G3,""))
 
Upvote 0
You're welcome. Thanks for the confirmation on both scenarios. :)
 
Upvote 0

Forum statistics

Threads
1,215,561
Messages
6,125,538
Members
449,236
Latest member
Afua

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