Unique Product ID - count if + rank???

room99oat

New Member
Joined
Nov 11, 2015
Messages
14
Office Version
  1. 2019
Platform
  1. Windows
Hello,

I want to do Unique Product ID for my items and I have my data as shown in table below.

Column B is main category and Column C is sub-category, what formula should i use for excel to return unique ID as shown in column A.

ID Breakdown: M = main category, S = sub category, 01 = item number.

Thank you.

#A
(Unique ID)
B
(Main Category)
C
(Sub-Category)
D
(Item Name)
1M1-S1-01VegetableOrganicAAA
2M2-S1-01SeafoodShrimpBBB
3M2-S1-02SeafoodShrimpBBB
4M2-S2-01SeafoodFishCCC-A
5M2-S2-02SeafoodFishCCC-B
6M2-S2-03SeafoodFishCCC-C
7M3-S1-01MeatPorkDDD-A
8M3-S1-02MeatPorkDDD-B
9M3-S2-01MeatChickenEEE-A
10M3-S2-02MeatChickenEEE-B
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi, maybe something along:
excel.xlsx
ABCDEFGHIJK
1#(Unique ID)(Main Category)(Sub-Category)(Item Name)Cat.codeCat.code
21M1-S1-01VegetableOrganicAAAVegetableM1OrganicS1
32M2-S1-01SeafoodShrimpBBBSeafoodM2ShrimpS1
43M2-S1-02SeafoodShrimpBBBMeatM3FishS2
54M2-S2-01SeafoodFishCCC-APorkS1
65M2-S2-02SeafoodFishCCC-BChickenS2
76M2-S2-03SeafoodFishCCC-C
87M3-S1-01MeatPorkDDD-A
98M3-S1-02MeatPorkDDD-B
109M3-S2-01MeatChickenEEE-A
1110M3-S2-02MeatChickenEEE-B
Sheet6
Cell Formulas
RangeFormula
B2:B11B2=TEXTJOIN("-",TRUE,XLOOKUP([@[(Main Category)]],MCat_table[Cat.],MCat_table[ code ],"not in DB",0),XLOOKUP([@[(Sub-Category)]],SCat_table[Cat.],SCat_table[ code ],"not in DB",0),TEXT(SUMPRODUCT(--(LEFT(E$2:E2,3)=LEFT(E2,3))),"00"))
 
Last edited by a moderator:
Upvote 0
what formula should i use
That will most likely depend on your version of Excel. Please update your Account details (found by clicking your user name at the top right of the forum) so that information is always available.
1582264268954.png
 
Upvote 0
cyrilbrd Thank you for you answer, but my 2019 version doesn't have xlookup. Are there any other ways?

Peter_SSs I use Excel 2019.
 
Last edited:
Upvote 0
@Peter_SSs I use Excel 2019.
Thanks for updating your profile with this info.

Could you use something like this? Helper information in columns G, H, .. (or could be on another worksheet).
List Main categories across row 1. In my formulas I have allowed for up to 10 main categories (columns H:Q)
Formula in H2 copied across to Q2
From row 3 list any sub-category values that migh apply to that main category. In my formula I have allowed for up to 10 sub-categories per main category. Just alter the $12 in my formula if you want to allow for more.
Formula in B2 copied down.

A_MrExcel.xlsm
ABCDEFGHIJKLMNOPQ
1#(Unique ID)(Main Category)(Sub-Category)(Item Name)VegetableSeafoodMeat
21M1-S1-01VegetableOrganicAAAM1M2M3       
32M2-S1-01SeafoodShrimpBBBOrganicShrimpPork
43M2-S1-02SeafoodShrimpBBBFishChicken
54M2-S2-01SeafoodFishCCC-A
65M2-S2-02SeafoodFishCCC-B
76M2-S2-03SeafoodFishCCC-C
87M3-S1-01MeatPorkDDD-A
98M3-S1-02MeatPorkDDD-B
109M3-S2-01MeatChickenEEE-A
1110M3-S2-02MeatChickenEEE-B
Sheet2 (2)
Cell Formulas
RangeFormula
H2:Q2H2=IF(H1="","","M"&COUNTA($H1:H1))
B2:B11B2=HLOOKUP(C2,H$1:Q$2,2,0)&"-S"&MATCH(D2,INDEX(H$3:Q$12,0,MATCH(C2,H$1:Q$1,0)),0)&TEXT(COUNTIFS(C$2:C2,C2,D$2:D2,D2),"-00")
 
Upvote 0
Or keeping the table system I suggested:
replace the formula using XLOOKUP with INDEX MATCH
 
Upvote 0
Book1
ABCDEFGHIJK
1#(Unique ID)(Main Category)(Sub-Category)(Item Name)Cat.nameCat.name
21M1-S1-01VegetableOrganicAAAVegetableM1OrganicS1
32M2-S1-01SeafoodShrimpBBBSeafoodM2ShrimpS1
43M2-S1-02SeafoodShrimpBBBMeatM3FishS2
54M2-S2-01SeafoodFishCCC-APorkS1
65M2-S2-02SeafoodFishCCC-BChickenS2
76M2-S2-03SeafoodFishCCC-C
87M3-S1-01MeatPorkDDD-A
98M3-S1-02MeatPorkDDD-B
109M3-S2-01MeatChickenEEE-A
1110M3-S2-02MeatChickenEEE-B
Sheet1
Cell Formulas
RangeFormula
B2:B11B2=TEXTJOIN("-",TRUE,INDEX(MCat_table[name],MATCH([@[(Main Category)]],MCat_table[Cat.],0)),INDEX(SCat_table[name],MATCH([@[(Sub-Category)]],SCat_table[Cat.],0)),TEXT(SUMPRODUCT(--(LEFT(E$2:E2,3)=LEFT(E2,3))),"00"))
 
Upvote 0

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

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