Extracting Multiple Value by Using Unique Value

93arpan

New Member
Joined
Aug 21, 2023
Messages
6
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I'm working with a dataset that has two columns: Transaction (Column A) and Client ID (Column B). I'm aiming to extract the Client ID values associated with a specific Transaction from Column A.

For example, if I select Transaction 100000223, I want to retrieve the corresponding Client ID values, which are "IN AG, AT AG, and NL AG". Similarly, for Transaction 100000254, I'd like to obtain "PL AG and IN AG".


Column A (Transaction)Column B (Client ID)
100000138 PL AG
100000145OG AG
100000151US AG
100000220 YU AG
100000223IN AG
100000223AT AG
100000223NL AG
100000254 PL AG
100000254 IN AG
 

Attachments

  • 2024-10-04 09_31_45-Workshing Sheet - Excel.png
    2024-10-04 09_31_45-Workshing Sheet - Excel.png
    16.4 KB · Views: 10

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Create a Parameter Query in Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Filtered Rows" = Table.SelectRows(Source, each ([Transaction] = Table2))
in
    #"Filtered Rows"

PQ Parameter.xlsx
ABCDEFGHIJ
1TransactionClient IDTransactionTransactionClient IDTransaction
2100000138PL AG100000145100000145OG AG100000138
3100000145OG AG100000145
4100000151US AG100000151
5100000220YU AGD1 is a lookup data validation from column J100000220
6100000223IN AGOnce this has been entered, click on Data-->Refresh All100000223
7100000223AT AGResults are in columns F:G100000254
8100000223NL AG
9100000254PL AG
10100000254IN AG
Sheet1
Cells with Data Validation
CellAllowCriteria
D2List=$J$2:$J$7
 
Upvote 0
Create a Parameter Query in Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Filtered Rows" = Table.SelectRows(Source, each ([Transaction] = Table2))
in
    #"Filtered Rows"

PQ Parameter.xlsx
ABCDEFGHIJ
1TransactionClient IDTransactionTransactionClient IDTransaction
2100000138PL AG100000145100000145OG AG100000138
3100000145OG AG100000145
4100000151US AG100000151
5100000220YU AGD1 is a lookup data validation from column J100000220
6100000223IN AGOnce this has been entered, click on Data-->Refresh All100000223
7100000223AT AGResults are in columns F:G100000254
8100000223NL AG
9100000254PL AG
10100000254IN AG
Sheet1
Cells with Data Validation
CellAllowCriteria
D2List=$J$2:$J$7
Thank you very much, I will try this using Power Query as majority of my transformation happens there, definitely going to try there
Also, outside Power query I found this excel formula helpful that gets the job done.
TEXTJOIN(", ",TRUE,UNIQUE(IF($A6=$A:$A,B:B,"")))
 
Upvote 0
You could also use TEXTJOIN with FILTER
Book1
ABCDEF
1Column A (Transaction)Column B (Client ID)
2100000138PL AG100000223IN AG, AT AG, NL AG
3100000145OG AG100000254PL AG, IN AG
4100000151US AG
5100000220YU AG
6100000223IN AG
7100000223AT AG
8100000223NL AG
9100000254PL AG
10100000254IN AG
Sheet1
Cell Formulas
RangeFormula
E2:E3E2=TEXTJOIN(", ",TRUE,FILTER(B$2:B$10,A$2:A$10=D2))
 
Upvote 0
With Excel for Microsoft 365, you could also try the new GROUPBY function. Some examples include:

Excel Formula:
=GROUPBY(A1:A10,B1:B10,ARRAYTOTEXT,3,0)

=GROUPBY(A1:A10,B1:B10,ARRAYTOTEXT,3,0,,A1:A10=100000223)

=GROUPBY(A1:A10,B1:B10,ARRAYTOTEXT,3,0,,(A1:A10>100000220)*(A1:A10<100000260))

=GROUPBY(A1:A10,B1:B10,ARRAYTOTEXT,3,0,,ISNUMBER(XMATCH(A1:A10,{100000223,100000254})))

Adjust the range references as needed; or, use an Excel table with structured references. For example:

Excel Formula:
=GROUPBY(Table1[[#All],[Transaction ID]],Table1[[#All],[Client ID]],ARRAYTOTEXT,3,0)
 
Upvote 0

Forum statistics

Threads
1,223,950
Messages
6,175,582
Members
452,653
Latest member
craigje92

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