Combine columns ignoring blanks

Seb_C

New Member
Joined
Nov 13, 2020
Messages
8
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I am new to the Query capabilities in excel. I have several tables that I am combining in various pairings and I have one table that can have multiple references to other tables in two columns.
The first column is essentially an index value for that table.
The second and third columns reference index values in other tables.

1605289272138.png


In the end I want to have segments from the three tables combined into one. If I separate the second and third columns by the ";" delimiter I end up with 16 rows for A_17 in the end (four each for C_003 and C_024, and 2 for each of the S* numbers) instead of 8.

When I merge the columns I end up with the image below - with extra delimiters at the null cells. How can I merge the columns and ignore the null cells / remove the unnecessary delimiters?
A second, minor, item would be to make the column delimiter "; " instead of ";" to make it visually cleaner since when breaking the combined column into rows some of the data will end up with a space in front of it (or if there was an easy way to remove the leading space when splitting the column into rows if the space exists in only some of the data).


1605289603921.png


Thank you.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
XL2BB for the images

Original data:
Matrix - Copy.xlsm
ABC
10A_08C_025
11A_09C_015S_013; S_026
12A_10C_027S_002; S_016
13A_11C_028S_007
14A_12C_027S_027
15A_13S_018
16A_14S_004
17A_15C_002S_014
18A_16S_026
19A_17C_003; C_024S_005; S_009; S_022; S_020
AIDT


Desired result: I can do it in excel, but I can't get it to function in the Query
Matrix - Copy.xlsm
ABCDE
1Desired result, but in a queryOriginal cells
2A_08C_025C_025
3A_09C_015; S_013; S_026C_015S_013; S_026
4A_10C_027; S_002; S_016C_027S_002; S_016
5A_11C_028; S_007C_028S_007
6A_12C_027; S_027C_027S_027
7A_13S_018S_018
8A_14S_004S_004
9A_15C_002; S_014C_002S_014
10A_16S_026S_026
11A_17C_003; C_024; S_005; S_009; S_022; S_020C_003; C_024S_005; S_009; S_022; S_020
Sheet2
Cell Formulas
RangeFormula
B2:B11B2=IF(E2="",D2,IF(D2="",E2,D2 &"; " &E2))
Cells with Data Validation
CellAllowCriteria
D2:D11List=Req_IDs
E2:E11List=Der_Req_IDs
 
Upvote 0
merge column 2 and column 3 with delimiter ; (semicolon) then use Text.Trim(merged. ";") and then remove unnecessary column

Column1Column2Column3Column1Custom
A_08C_025A_08C_025
A_09C_015S_013; S_026A_09C_015;S_013; S_026
A_10C_027S_002; S_016A_10C_027;S_002; S_016
A_11C_028S_007A_11C_028;S_007
A_12C_027S_027A_12C_027;S_027
A_13S_018A_13S_018
A_14S_004A_14S_004
A_15C_002S_014A_15C_002;S_014
A_16S_026A_16S_026
A_17C_003; C_024S_005; S_009; S_022; S_020A_17C_003; C_024;S_005; S_009; S_022; S_020
 
Upvote 0

Forum statistics

Threads
1,223,757
Messages
6,174,330
Members
452,555
Latest member
colc007

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