Extract Unique Values From A Single Cell Formula

legalhustler

Well-known Member
Joined
Jun 5, 2014
Messages
1,162
Office Version
  1. 365
Platform
  1. Windows
I have a single cell formula that uses the TEXTJOIN function and returns multiple values. Although some answers are returning duplicate values (which is working as designed b/c multiple instances do appear when I do the look up), but I want to only show the unique values in my single cell solution. For example my formula is returning the following in a single cell, separated by commas:

5,15,20,15,25

I want to further amend my formula below so that it only shows 5,15,20, 25

={TEXTJOIN(",",1,IF(Customers!$B$1:$B$1000=$A3,IDs!$A$1:$A$1000,""))}

Any help is appreciated. TIA!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try one of these formulas.
If you have Excel 365 use formula in C4.
If not try the array formula in C2. Enter with CTRL-SHIFT-ENTER.

CUSTOMER sheet
Book1
ABC
1Cust1
2Cust25,15,20,25
3Cust1Cust1
4Cust25,15,20,25
5Cust1
6Cust6
7Cust2
8Cust1
9Cust9
10Cust10
11Cust1
Customers
Cell Formulas
RangeFormula
C2C2{=TEXTJOIN(",",1,IF(IF($B$1:$B$1000=$A$3,MATCH(IDs!$A$1:$A$1000,IDs!$A$1:$A$1000,0)=MATCH(ROW(IDs!$A$1:$A$1000),ROW(IDs!$A$1:$A$1000)))=TRUE,IDs!$A$1:$A$1000,""))}
C4C4=TEXTJOIN(",",1,UNIQUE(IF(Customers!$B$1:$B$1000=$A3,IDs!$A$1:$A$1000,"")))
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.


ID sheet
Book1
ABC
15Cust1
22Cust2
315Cust1
44Cust2
520Cust1
66Cust6
77Cust2
815Cust1
99Cust9
1010Cust10
1125Cust1
IDs
 
Upvote 0
I don't have Dynamic Arrays. I tried the first formula with CSE but it returned a blank when I was expecting it to show some values. I modified my original formula in post #1 to make it easier to read, but that may have been a mistake. So here is my real formula:

=TEXTJOIN(",",1,IF(INDIRECT(E$1&"!$B$1:$B$1000")=$A4&"",INDIRECT(E$1&"!$A$1:$A$1000"),"")

Note: $A4&"" is referencing the current sheet and the ranges inside of both INDIRECT is reference another sheet.

Can you please amend that to your option 1 format? Also, any way to enhance your option 1 formula so it doesn't use CSE?

Thanks.
 
Upvote 0
Sorry, I'm not sure how you would do it using a formula. It maybe something that would have to be done using VBA. It would probably be easier for someone to help if you would post a small sample.
 
Upvote 0
Try:

=TEXTJOIN(",",1,IFERROR(IF(MATCH(A3&"|"&IDs!$A$1:$A$1000,Customers!$B$1:$B$1000&"|"&IDs!$A$1:$A$1000,0)=ROW(Customers!$A$1:$A1000),IDs!$A$1:$A$1000,""),""))

with CSE.
 
Upvote 0
Try:

=TEXTJOIN(",",1,IFERROR(IF(MATCH(A3&"|"&IDs!$A$1:$A$1000,Customers!$B$1:$B$1000&"|"&IDs!$A$1:$A$1000,0)=ROW(Customers!$A$1:$A1000),IDs!$A$1:$A$1000,""),""))

with CSE.

Can you help extract unique values from the results of my current formula below?

=TEXTJOIN(",",1,IF(INDIRECT(E$1&"!$B$1:$B$1000")=$A4&"",INDIRECT(E$1&"!$A$1:$A$1000"),"")
 
Upvote 0
Try:

=TEXTJOIN(",",1,IFERROR(IF(MATCH($A4&"|"&INDIRECT(E$1&"!A1:A1000"),INDIRECT(E$1&"!B1:B1000")&"|"&INDIRECT(E$1&"!A1:A1000"),0)=ROW(INDIRECT(E$1&"!A1:A1000"))-ROW(INDIRECT(E$1&"!A1"))+1,INDIRECT(E$1&"!A1:A1000"),""),""))

with CSE.
 
Upvote 0
ALso you can use Unique function if you are using office 365
=TEXTJOIN(",",1,UNIQUE(IF(Customers!$B$1:$B$1000=$A3,IDs!$A$1:$A$1000,"")))
 
Upvote 0
Book3
ABCD
1Cust1
2Cust2
3Cust1Cust15,15,20,25
4Cust2
5Cust1
6Cust6 
7Cust2
8Cust1
9Cust9
10Cust10
11Cust1
Sheet3
Cell Formulas
RangeFormula
D3D3=TEXTJOIN(",",TRUE,IFERROR(IF(FREQUENCY(INDEX(IDs!$A$1:$A$11,IF(IDs!$C$1:$C$11=Sheet3!C3,ROW(1:11))),INDEX(IDs!$A$1:$A$11,IF(IDs!$C$1:$C$11=Sheet3!C3,ROW(1:11))))>0,1,"")*INDEX(IDs!$A$1:$A$11,IF(IDs!$C$1:$C$11=Sheet3!C3,ROW(1:11))),""))
D6D6=TEXTJOIN(",",1,IFERROR(IF(MATCH($A4&"|"&INDIRECT(E$1&"!A1:A1000"),INDIRECT(E$1&"!B1:B1000")&"|"&INDIRECT(E$1&"!A1:A1000"),0)=ROW(INDIRECT(E$1&"!A1:A1000"))-ROW(INDIRECT(E$1&"!A1"))+1,INDIRECT(E$1&"!A1:A1000"),""),""))
 
Upvote 0
Try:

=TEXTJOIN(",",1,IFERROR(IF(MATCH($A4&"|"&INDIRECT(E$1&"!A1:A1000"),INDIRECT(E$1&"!B1:B1000")&"|"&INDIRECT(E$1&"!A1:A1000"),0)=ROW(INDIRECT(E$1&"!A1:A1000"))-ROW(INDIRECT(E$1&"!A1"))+1,INDIRECT(E$1&"!A1:A1000"),""),""))

with CSE.


Hi,
Can you please post your excel sheet.. I am a bit confused with the E1 Cell
 
Upvote 0

Forum statistics

Threads
1,214,617
Messages
6,120,541
Members
448,970
Latest member
kennimack

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