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]smwd_wo_quote_nbr[/FONT]
[FONT=&quot]smwd_seq[/FONT]
[FONT=&quot]smwd_text[/FONT]
[FONT=&quot]smwd_flag[/FONT]
[FONT=&quot]1[/FONT]​
[FONT=&quot]1[/FONT]​
[FONT=&quot]breakaway off of pump #2[/FONT]
[FONT=&quot]W[/FONT]
[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]1[/FONT]​
[FONT=&quot]DISPENSER 1 MIDGRADE PUMP NOT[/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]1[/FONT]​
[FONT=&quot]Dispenser on midgrade not[/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]1[/FONT]​
[FONT=&quot]Dispenser 1 not pumping. Hose[/FONT]
[FONT=&quot]W[/FONT]
[FONT=&quot]16[/FONT]​
[FONT=&quot]2[/FONT]​
[FONT=&quot]fell off.[/FONT]
[FONT=&quot]W[/FONT]

<tbody>
</tbody>
 
Last edited:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
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

smwd_wo_quote_nbrsmwd_seqsmwd_textsmwd_flagsmwd_wo_quote_nbrsmwd_text
1​
1​
breakaway off of pump #2W
1​
breakaway off of pump #2
3​
1​
Test for External Customer.W
3​
Test for External Customer.
9​
1​
DISPENSER 1 MIDGRADE PUMP NOTW
9​
DISPENSER 1 MIDGRADE PUMP NOT WORKING.
9​
2​
WORKING.W
10​
Dispenser on midgrade not working.
10​
1​
Dispenser on midgrade notW
16​
Dispenser 1 not pumping. Hose fell off.
10​
2​
working.W
16​
1​
Dispenser 1 not pumping. HoseW
16​
2​
fell off.W

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,215,219
Messages
6,123,685
Members
449,117
Latest member
Aaagu

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