【问题标题】:Lookup multiple values in a single cell (comma separated) and then return the values to a single cell (also comma separated)在单个单元格中查找多个值(逗号分隔),然后将值返回到单个单元格(也以逗号分隔)
【发布时间】:2024-04-27 20:00:02
【问题描述】:

使用 Google 表格,我有以下两个表格:

第一张桌子

Size   | Code
--------------
Large  | L
Small  | S
XLarge | XL

第二张桌子

Values       | Codes
-------------------
Large,Small  | L,S
XLarge,Small | XL,S
XLarge,large | XL,L

我需要Codes 列上的查找函数来返回相应值的代码。

当我使用时:

=LOOKUP(Values Column,Size,Code)

我只有一个代码,例如 L。 如何获取代码: (L,S) (XL,S) (XL,L) 等?

【问题讨论】:

  • 请不要在标题中强行添加标签。请参阅 es.*.com/help/tagging。此外,如果问题完全是关于 google-spreadsheet 的,请不要包括 excel,因为虽然两者都是电子表格应用程序,但它们有几件事不能以相同的方式工作。

标签: google-sheets google-sheets-formula array-formulas google-sheets-vlookup


【解决方案1】:

您必须拆分它们,进行 vlookup,然后连接结果

=arrayformula(left(concatenate(vlookup(split(D2,","),$A$2:$B$4,2,false)&","),len(concatenate(vlookup(split(D2,","),$A$2:$B$4,2,false)&","))-1))

我的查找表在 A2:B4 中,值从 D2 开始。

【讨论】:

    【解决方案2】:

    您可以尝试查询。如果表 1 在 Sheet1 中,表 2 在 Sheet2 中,在 Sheet3 中输入要在 A2 中查找的尺寸(即'S'),然后在 B2 中输入此查询:

     =Query({Sheet1!A2:B4,Sheet2!A2:B4},"Select Col4 where Col4 contains '"&A2&"'")
    

    【讨论】: