Forum Discussion
Extract different player names referring to an identical text string into separate columns.
- Dec 02, 2019
Let transform identifiers such way
i.e. <space><identifier><space><sequential number of identifier>
When formula in D2 could be
=IFERROR(MID($B2, SEARCH( REPT("@",LEN(LEFT(D$1,LEN(D$1)-1))), SUBSTITUTE( " " & $B2, LEFT(D$1,LEN(D$1)-1), REPT("@",LEN(LEFT(D$1,LEN(D$1)-1))), RIGHT(D$1)) ) + LEN(D$1)-2, IFERROR( AGGREGATE(15,6, 1/( SEARCH( REPT("@",LEN(LEFT($D$1:$L$1,LEN($D$1:$L$1)-1))), SUBSTITUTE( " " & $B2, LEFT($D$1:$L$1,LEN($D$1:$L$1)-1), REPT("@",LEN(LEFT($D$1:$L$1,LEN($D$1:$L$1)-1))), RIGHT($D$1:$L$1) ) )-1 > SEARCH( REPT("@",LEN(LEFT(D$1,LEN(D$1)-1))), SUBSTITUTE( " " & $B2, LEFT(D$1,LEN(D$1)-1), REPT("@",LEN(LEFT(D$1,LEN(D$1)-1))), RIGHT(D$1) ) ) )* SEARCH( REPT("@",LEN(LEFT($D$1:$L$1,LEN($D$1:$L$1)-1))), SUBSTITUTE( " " & $B2, LEFT($D$1:$L$1,LEN($D$1:$L$1)-1), REPT("@",LEN(LEFT($D$1:$L$1,LEN($D$1:$L$1)-1))), RIGHT($D$1:$L$1) ) ),1 ), LEN($B2)+1 ) - SEARCH( REPT("@",LEN(LEFT(D$1,LEN(D$1)-1))), SUBSTITUTE( " " & $B2, LEFT(D$1,LEN(D$1)-1), REPT("@",LEN(LEFT(D$1,LEN(D$1)-1))), RIGHT(D$1) ) ) - LEN(D$1)+1 ),"")
when drag to the right and down (or better use Ctrl+D).
Perhaps formula could be optimized, but it will take time to play with it and find another way if any. Right now it takes few minutes to fill couple hundred thousand rows. Thus better to test on few ones.
That is in second sheet of the attached file.
UPDATE: I failed to upload the file, will try once more tomorrow.
The easiest and simplest way is to do that with Power Query, I updated it with duplication remove in old file (second sheet).
Since you consider only formulas - don't know right now what and how to do.
- stevecccDec 02, 2019Brass Contributor
Sergei, is there an way to search and replace the separators with different names? I couldn't figure it out, but if so that would make your formula solution work. For example,
Original data:
QB Drew Brees RB Alvin Kamara FLEX Leonard Fournette RB Brian Hill WR DJ Moore WR Jarvis Landry WR Allen Hurns TE Jared Cook DST Broncos
Data with new separators:
QB Drew Brees RB1 Alvin Kamara FLEX Leonard Fournette RB2 Brian Hill WR1 DJ Moore WR2 Jarvis Landry WR3 Allen Hurns TE Jared Cook DST Broncos
How to quickly change the name of the separators? Find/Replace does not work. I imagine it requires some combination of COUNT, AND, OR.- SergeiBaklanDec 02, 2019Diamond Contributor
And which exactly formula do you mean? If as in Sheet1 (5) in attached file you only need to change headers of resulting columns on new separators
The only don't forget to wrap each separator by spaces. The could be automated a bit, but let define first what is required.
- stevecccDec 02, 2019Brass Contributor
Hi Sergei. It seems like you are using NBA (basketball) player data as an example. But for this question, we should be using the NFL (football) player instead (please see attached).
Your original formula solution for NBA player data worked because each player was referenced by a unique identifier.
However, your formula solution for NFL player data does not work because the NFL data uses shared identifiers for each position.Let's look at the data in Cell B2 in the attached example of NFL player data:
QB Carson Wentz RB Christian McCaffrey RB Miles Sanders WR Davante Adams WR DeVante Parker FLEX Alshon Jeffery WR Dede Westbrook TE Tyler Higbee DST Chiefs
On the Excel worksheet, Identifiers are in D1:L1
Here is how the data appears in D2:L2 using your formulas:
Carson Wentz R Christian McCaffrey RB Miles Sanders W Christian McCaffrey RB Miles Sanders W Davant Davant Davant Adams WR DeVante Parker F Alshon Jeffery WR Dede Westbrook TE Tyler Higbee D ChiefsObviously this is not working properly. However, if there was a way to change the Column B data so that the shared identifiers (RB, RB, WR, WR, WR) are changed into unique names (RB 1, RB2, WR1, WR2, WR3), then your original formula solution would work.
In summary, some kind of find/replace solution is needed for transforming the shared identifiers (RB, RB, WR, WR, WR) in Column B into unique identifiers (RB1, RB2, WR1, WR2, WR3).
- SergeiBaklanDec 02, 2019Diamond Contributor
Separators are the same for all records? I mean one set of separators for one file, another set for another file, but within the file they are the same for all records, correct?
- stevecccDec 02, 2019Brass Contributor
SergeiBaklan Thanks very much Sergei. I very much appreciate it. I will look into using Power Query.