How to combine rows where column is equal. Weird source data layout.

Jemmick

New Member
Joined
Mar 25, 2013
Messages
8
I am querying a database that is setup in a weird fashion. It has a work order field, a index field, and a text field. So below work order "9" says "DISPENSER 1 MIDGRADE PUMP NOT WORKING" and as you can see 9 has two sequence numbers. I need to find a way to combine these into 1 row that would have just the number 9 and the text. Anyone have any recommendations?


1f59826d-191e-4338-9bf7-7b848ec91e82

[FONT=&quot]3[/FONT]​
[FONT=&quot]1[/FONT]​
[FONT=&quot]Test for External Customer.[/FONT]
[FONT=&quot]W[/FONT]
[FONT=&quot]9[/FONT]​
[FONT=&quot]2[/FONT]​
[FONT=&quot]WORKING.[/FONT]
[FONT=&quot]W[/FONT]
[FONT=&quot]10[/FONT]​
[FONT=&quot]2[/FONT]​
[FONT=&quot]working.[/FONT]
[FONT=&quot]W[/FONT]
[FONT=&quot]16[/FONT]​
[FONT=&quot]2[/FONT]​
[FONT=&quot]fell off.[/FONT]
[FONT=&quot]W[/FONT]

<tbody>
[TD="bgcolor: #333399"] [FONT=&quot]smwd_wo_quote_nbr[/FONT]
[/TD]
[TD="bgcolor: #333399"] [FONT=&quot]smwd_seq[/FONT]
[/TD]
[TD="bgcolor: #333399"] [FONT=&quot]smwd_text[/FONT]
[/TD]
[TD="bgcolor: #333399"] [FONT=&quot]smwd_flag[/FONT]
[/TD]

[TD="bgcolor: #ccccff"]
[FONT=&quot]1[/FONT]​
[/TD]
[TD="bgcolor: #ccccff"]
[FONT=&quot]1[/FONT]​
[/TD]
[TD="bgcolor: #ccccff"][FONT=&quot]breakaway off of pump #2[/FONT]
[/TD]
[TD="bgcolor: #ccccff"][FONT=&quot]W[/FONT]
[/TD]

[TD="bgcolor: #ccccff"]
[FONT=&quot]9[/FONT]​
[/TD]
[TD="bgcolor: #ccccff"]
[FONT=&quot]1[/FONT]​
[/TD]
[TD="bgcolor: #ccccff"][FONT=&quot]DISPENSER 1 MIDGRADE PUMP NOT[/FONT]
[/TD]
[TD="bgcolor: #ccccff"][FONT=&quot]W[/FONT]
[/TD]

[TD="bgcolor: #ccccff"]
[FONT=&quot]10[/FONT]​
[/TD]
[TD="bgcolor: #ccccff"]
[FONT=&quot]1[/FONT]​
[/TD]
[TD="bgcolor: #ccccff"][FONT=&quot]Dispenser on midgrade not[/FONT]
[/TD]
[TD="bgcolor: #ccccff"][FONT=&quot]W[/FONT]
[/TD]

[TD="bgcolor: #ccccff"]
[FONT=&quot]16[/FONT]​
[/TD]
[TD="bgcolor: #ccccff"]
[FONT=&quot]1[/FONT]​
[/TD]
[TD="bgcolor: #ccccff"][FONT=&quot]Dispenser 1 not pumping. Hose[/FONT]
[/TD]
[TD="bgcolor: #ccccff"][FONT=&quot]W[/FONT]
[/TD]

</tbody>
 
Last edited:

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi Jemmick,

Can you use this? Does the "smwd_text" rows ever exceed 2 rows?


Book1
ABCDE
1smwd_wo_quote_nbrsmwd_seqsmwd_textsmwd_flagHelper
211breakaway off of pump #2Wbreakaway off of pump #2
331Test for External Customer.WTest for External Customer.
491DISPENSER 1 MIDGRADE PUMP NOTWDISPENSER 1 MIDGRADE PUMP NOT WORKING.
592WORKING.W
6101Dispenser on midgrade notWDispenser on midgrade not working.
7102working.W
8161Dispenser 1 not pumping. HoseWDispenser 1 not pumping. Hose fell off.
9162fell off.W
Sheet1
Cell Formulas
RangeFormula
E2{=IF(A2=A1,"",IF(COUNTIF($A$2:$A$9,A2)=2,INDEX($C$2:$C$9,SMALL(IF($A$2:$A$9=A2,ROW($A$2:$A$9)-ROW($A$2)+1),1))&" "&INDEX($C$2:$C$9,SMALL(IF($A$2:$A$9=A2,ROW($A$2:$A$9)-ROW($A$2)+1),2)),INDEX($C$2:$C$9,SMALL(IF($A$2:$A$9=A2,ROW($A$2:$A$9)-ROW($A$2)+1),1))))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0
Hi Jemmick,

Can you use this? Does the "smwd_text" rows ever exceed 2 rows?


Book1
ABCDE
1smwd_wo_quote_nbrsmwd_seqsmwd_textsmwd_flagHelper
211breakaway off of pump #2Wbreakaway off of pump #2
331Test for External Customer.WTest for External Customer.
491DISPENSER 1 MIDGRADE PUMP NOTWDISPENSER 1 MIDGRADE PUMP NOT WORKING.
592WORKING.W
6101Dispenser on midgrade notWDispenser on midgrade not working.
7102working.W
8161Dispenser 1 not pumping. HoseWDispenser 1 not pumping. Hose fell off.
9162fell off.W
Sheet1
Cell Formulas
RangeFormula
E2{=IF(A2=A1,"",IF(COUNTIF($A$2:$A$9,A2)=2,INDEX($C$2:$C$9,SMALL(IF($A$2:$A$9=A2,ROW($A$2:$A$9)-ROW($A$2)+1),1))&" "&INDEX($C$2:$C$9,SMALL(IF($A$2:$A$9=A2,ROW($A$2:$A$9)-ROW($A$2)+1),2)),INDEX($C$2:$C$9,SMALL(IF($A$2:$A$9=A2,ROW($A$2:$A$9)-ROW($A$2)+1),1))))}
Press CTRL+SHIFT+ENTER to enter array formulas.


Yes it has up to 54 rows on one record
 
Upvote 0
maybe with PowerQuery

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]smwd_wo_quote_nbr[/td][td=bgcolor:#5B9BD5]smwd_seq[/td][td=bgcolor:#5B9BD5]smwd_text[/td][td=bgcolor:#5B9BD5]smwd_flag[/td][td][/td][td=bgcolor:#70AD47]smwd_wo_quote_nbr[/td][td=bgcolor:#70AD47]smwd_text[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]breakaway off of pump #2[/td][td=bgcolor:#DDEBF7]W[/td][td][/td][td=bgcolor:#E2EFDA]
1​
[/td][td=bgcolor:#E2EFDA]breakaway off of pump #2[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
3​
[/td][td]
1​
[/td][td]Test for External Customer.[/td][td]W[/td][td][/td][td]
3​
[/td][td]Test for External Customer.[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
9​
[/td][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]DISPENSER 1 MIDGRADE PUMP NOT[/td][td=bgcolor:#DDEBF7]W[/td][td][/td][td=bgcolor:#E2EFDA]
9​
[/td][td=bgcolor:#E2EFDA]DISPENSER 1 MIDGRADE PUMP NOT WORKING.[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
9​
[/td][td]
2​
[/td][td]WORKING.[/td][td]W[/td][td][/td][td]
10​
[/td][td]Dispenser on midgrade not working.[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
10​
[/td][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]Dispenser on midgrade not[/td][td=bgcolor:#DDEBF7]W[/td][td][/td][td=bgcolor:#E2EFDA]
16​
[/td][td=bgcolor:#E2EFDA]Dispenser 1 not pumping. Hose fell off.[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
10​
[/td][td]
2​
[/td][td]working.[/td][td]W[/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
16​
[/td][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]Dispenser 1 not pumping. Hose[/td][td=bgcolor:#DDEBF7]W[/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
16​
[/td][td]
2​
[/td][td]fell off.[/td][td]W[/td][td][/td][td][/td][td][/td][/tr]
[/table]


Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Grouped Rows" = Table.Group(Source, {"smwd_wo_quote_nbr"}, {{"Count", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "smwd_text", each Table.Column([Count],"smwd_text")),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"smwd_text", each Text.Combine(List.Transform(_, Text.From), " "), type text}),
    #"Removed Columns" = Table.RemoveColumns(#"Extracted Values",{"Count"})
in
    #"Removed Columns"[/SIZE]
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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