excelexcel-formula

How to Combine Text Based on Multiple Criteria in Excel


I'm not sure if the title makes sense, but here is what I am looking for:

I have a table similar to the below table 1.

enter image description here

The result I am looking for is in cell A3, the combination of the account numbers for all devices associated with that store number.

Table 2 contains a list of the concepts and their associated account number. Column E is currently a validation list coming from table 2. For any computer type that is not a BOS, the account number uses a VLOOKUP based on column E (concept).

I'm looking for a way to concantate the account numbers based on the store number for a BOS.

Please let me know if more info is needed.

Thanks


Solution

  • I can propose you this solution (for ranges):

    enter image description here

    [A3]=LET(tbl,D3:E23,cncpts,G3:H27,
      s,TAKE(tbl,,1),a,XLOOKUP(TAKE(tbl,,-1),TAKE(cncpts,,1),TAKE(cncpts,,-1)),
      MAP(a,s,LAMBDA(x,y,LET(t,DROP(FILTER(a,s=y,a),1),IF(x=0,MIN(t)&" / "&MAX(t),x))))
    )
    

    Or

    [A3]=LET(tbl,D3:E23,cncpts,G3:H27,
      s,TAKE(tbl,,1),a,XLOOKUP(TAKE(tbl,,-1),TAKE(cncpts,,1),TAKE(cncpts,,-1)),
      MAP(a,s,LAMBDA(x,y,IF(x=0,TEXTJOIN(" / ",1,UNIQUE(DROP(FILTER(a,s=y,a),1))),x))))
    

    Depending on what you need.

    The solution is based on the keyword "Split" and Store Number. Items can be not ordered.

    UPD

    The solution for tables (the formula for Table1, column A):

    =LET(a,XLOOKUP([@Concept],Table2[ConceptName],Table2[Acct]),
      sn,FILTER([Concept],[Store Number]=[@[Store Number]]),
      xup,XLOOKUP(sn,Table2[ConceptName],Table2[Acct]),
      IF(a=0,TEXTJOIN("/",1,DROP(UNIQUE(xup),1)),a))