Forum Discussion
Joh_Loh
Apr 24, 2024Copper Contributor
How to create an autonumbering formula based on three columns
Update: Black cat on Stack Overflow gave the following formula that worked great: =MATCH(A2,UNIQUE(A$2:A2),0)&"."&MATCH(B2,UNIQUE(FILTER(B$2:B2,A2=A$2:A2)),0)&"."&MATCH(C2,UNIQUE(FILTER($C$2:$C2,A$...
djclements
Apr 25, 2024Silver Contributor
Joh_Loh If your data is formatted as a structured Excel table, one possible calculated column formula could be:
=LET(
ua, UNIQUE([Make]),
ub, UNIQUE(Table1[[Make]:[Model]]),
uc, UNIQUE(Table1[[Make]:[Colour]]),
TEXTJOIN(".",,
XMATCH([@Make], ua),
XMATCH([@Model], FILTER(CHOOSECOLS(ub, 2), CHOOSECOLS(ub, 1)=[@Make])),
XMATCH([@Colour], FILTER(CHOOSECOLS(uc, 3), (CHOOSECOLS(uc, 1)=[@Make])*(CHOOSECOLS(uc, 2)=[@Model])))
)
)
As a dynamic array variant, with the MAP function:
=LET(
ua, UNIQUE(A2:A14),
ub, UNIQUE(A2:B14),
uc, UNIQUE(A2:C14),
MAP(A2:A14, B2:B14, C2:C14,
LAMBDA(a,b,c,
TEXTJOIN(".",,
XMATCH(a, ua),
XMATCH(b, FILTER(CHOOSECOLS(ub, 2), CHOOSECOLS(ub, 1)=a)),
XMATCH(c, FILTER(CHOOSECOLS(uc, 3), (CHOOSECOLS(uc, 1)=a)*(CHOOSECOLS(uc, 2)=b)))
)
)
)
)
See attached sample workbook, if necessary...
Joh_Loh
Apr 25, 2024Copper Contributor
Thanks for the response, I went with a formula that I have added to the original post