Unique Identifier based on concatenated cell

DBoutwell

New Member
Joined
Oct 19, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I searched the archives and could not find an exact match for the problem I am facing. Please point me in the right direction if this was already answered.

I am trying to create a unique identifier for services based on customer code, city, location type (APT or TO), and a number.

2-Letter code + Airport code + Location type will be concatenated into a single cell and then appended with a number. The number needs to increment to tell me how many services a customer has at that city/location.

E.g.
AB + MAD + APT + nnn = ABMADAPT001
AB + MAD + APT + nnn = ABMADAPT002
AB + MAD + TO + nnn = ABMADTO001
XY + MAD + APT + nnn = XYMADAPT001
XY + LHR + TO + nnn = XYLHRTO001
XY + LHR + TO + nnn = XYLHRTO0002

2 letter codeApt CodeLocation typeConcatIdentifier
ABMADAPTABMADAPTABMADAPT001
ABMADAPTABMADAPTABMADAPT002
ABMADTOABMADTOABMADTO001
XYMADAPTXYMADAPTXYMADAPT001
XYLHRTOXYLHRTOXYLHRTO001
XYLHRTOXYLHRTOXYLHRTO002

The sequential number needs to be based on the number of services the customer has at that location. If customer "AB" has two services at the MAD airport, the IDs should be ABMADAPT001 and ABMADAPT002. If customer "XY" wants to start their first service at MAD airport, their ID would be XYMADAPT001.

ROW does not work since it will increment by 1 and will not take new customers into account.

Maybe Excel is not the tool for this.

Thanks in advance.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi & welcome to MrExcel.
How about
Excel Formula:
=CONCAT(A2:C2)&TEXT(COUNTIFS(A$2:A2,A2,B$2:B2,B2,C$2:C2,C2),"000")
 
Upvote 0
Solution
Power Query:
Can be achieved with Power Query/Get and Transform Data found on the Data Tab

let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Inserted Merged Column" = Table.AddColumn(Source, "ID", each Text.Combine({[2 letter code], [Apt Code], [Location type]}, ""), type text),
    #"Grouped Rows" = Table.Group(#"Inserted Merged Column", {"ID"}, {{"Data", each _, type table [2 letter code=text, Apt Code=text, Location type=text, ID=text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Data],"Index",1,1)),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Index"}, {"Custom.Index"}),
    #"Inserted Merged Column1" = Table.AddColumn(#"Expanded Custom", "Unique ID", each Text.Combine({[ID], Text.From([Custom.Index], "en-US")}, ""), type text),
    #"Removed Columns" = Table.RemoveColumns(#"Inserted Merged Column1",{"ID", "Data", "Custom.Index"})
in
    #"Removed Columns"

This will auto update every time you update the source table by selecting Refresh All
 
Upvote 0
Thanks for the fast answers. The answer from Fluff worked well. However, I will take a look at the Power Query as well.

Thanks again !!!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,694
Messages
6,126,252
Members
449,305
Latest member
Dalyb2

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