r/excel • u/InvisibleJune • 22d ago
unsolved I need to unify rows with duplicate data while keeping all different values
Hi everyone, in order to explain better I'll just make an example.
I have something like this:
| ID | Topic |
|---|---|
| 001 | apple |
| 001 | banana |
| 002 | apple |
| 003 | cherry |
| 003 | avocado |
| 004 | cherry |
| 004 | apple |
| 004 | banana |
And I need to automatically transform it into something like this:
| ID | Topic1 | Topic2 | Topic3 |
|---|---|---|---|
| 001 | apple | banana | |
| 002 | apple | ||
| 003 | cherry | avocado | |
| 004 | cherry | apple | banana |
In the actual file, I have thousands of rows and a lot of columns. In the file, I have multiple columns where the data is the same, while other information is different, and I need to have a unique row for each ID.
My experience with Excel is above average, but definitely not high, and I'm stuck on this passage.
Do you have any suggestions?
Thanks in advance!
7
u/RuktX 313 22d ago
Does your experience extend to Power Query? This would be a fairly straightforward Group > Text.Combine > Split Column.
2
1
u/MoltoBeneGesserit 22d ago
Yeah this is a good call. Had to use power query like this for work and this should do the trick.
4
u/MayukhBhattacharya 1327 22d ago
Try using the following formula:

=LET(
_a, A:.B,
_b, INDEX(_a, , 1),
_c, MAP(_b, LAMBDA(x, COUNTIF(INDEX(_b, 1):x, x))),
_d, PIVOTBY(_b,
TAKE(_a, 1, -1) & " " & _c,
CHOOSECOLS(_a, 2),
SINGLE, 1, 0, , 0),
IFNA(EXPAND("ID\Topic", 2, 2), _d))Or, same formula without using the MAP()
=LET(
_a, A:.B,
_b, INDEX(_a, , 1),
_c, SEQUENCE(ROWS(_b), , 2) - XMATCH(_b, _b),
_d, PIVOTBY(_b,
TAKE(_a, 1, -1) & " " & _c,
CHOOSECOLS(_a, 2),
SINGLE, 1, 0, , 0),
IFNA(EXPAND("ID\Topic", 2, 2), _d))3
u/Akanaton 22d ago
I think you could do this in a tabular pivot table without subtotals or the Harray/horizontal array formula
3
2
u/Decronym 22d ago edited 19d ago
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
Decronym is now also available on Lemmy! Requests for support and new installations should be directed to the Contact address below.
Beep-boop, I am a helper bot. Please do not verify me as a solution.
27 acronyms in this thread; the most compressed thread commented on today has 15 acronyms.
[Thread #49665 for this sub, first seen 11th Nov 2026, 15:08] [FAQ] [Full list] ^[Contact] [Source code]
1
u/carbonizedtitanium 2 19d ago
on your second sheet:
A2: =Unique(Filter(Sheet1!A2:A10000, Sheet1!A2:A10000>0))
B2: =Transpose(Filter(Sheet1!$B$2:$B$10000, A2=Sheet1!$A$2:$A$10000)) drag formula down
0
u/ShittyAnimorph 21d ago
Buncha tryhards trying to solve it in a single formula... (I kid)
Here's what I'd do: Sort by id, then by topic. The below assumes row 1 is headers. Put it in c2 and carry down.
=If(a2<>a1, b2, if(b2=b3,c3,c3&","&b2,c3))
Open a new sheet and paste in your ID column then remove duplicates. Then do
=Textsplit(vlookup(a2,originalsheet!a:c,3,false),",")
Then copy paste that whole sheet as values and you're done.
0
21d ago
[removed] — view removed comment
1
u/InvisibleJune 20d ago
Hi, thank you! I have never used Power Query before, so I'm trying to understand how to do this (or any of the suggested things from other commenters). I managed easily to arrive until the second point, but I have no idea how to do the third one (Keep ID and the indexed table column; expand Topic and the index. Pivot the index column using Topic as the values and Don't aggregate). I am looking for tutorials online to see what I'm missing, but in the end I can't find how to do it. Would you be able to explain it to me or do you have any external source I could use for this?
0
19d ago edited 19d ago
[removed] — view removed comment
1
u/AutoModerator 19d ago
I have detected code containing Fancy/Smart Quotes which Excel does not recognize as a string delimiter. Edit to change those to regular quote-marks instead. This happens most often with mobile devices. You can turn off Fancy/Smart Punctuation in the settings of your Keyboard App.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.



•
u/AutoModerator 22d ago
/u/InvisibleJune - Your post was submitted successfully.
Once your problem is solved, reply to the answer(s) saying
Solution Verifiedto close the thread.Follow the submission rules -- particularly 1 and 2. To fix the body, click edit. To fix your title, delete and re-post.
Include your Excel version and all other relevant information
Failing to follow these steps may result in your post being removed without warning.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.