简体   繁体   English

是否可以使用两个标准单元格从第三列返回值?

[英]Is it possible to use two cells of criteria to return a value from a third column?

I have an Google sheets file with two sheets.我有一个带有两张纸的 Google 表格文件。 I'm trying to reference one sheet's text based on two cells of criteria using a formula in the other sheet.我正在尝试使用另一张表中的公式根据两个标准单元格引用一张表的文本。 I have one sheet that looks similar to this -我有一张看起来与此类似的表-

表 1

And another that looks like this -另一个看起来像这样 -

表 2

I would like to put a formula on the second sheet that basically says - look on the first sheet for the values in columns A and B and return me the value in column C.我想在第二张纸上放一个公式,基本上说 - 在第一张纸上查看 A 和 B 列中的值,然后将 C 列中的值返回给我。 The tricky part is - the values in the second sheet may be inverted or there may be an instance where only one value is present, like in row 1 in the first sheet.棘手的部分是 - 第二张表中的值可能会被反转,或者可能存在仅存在一个值的情况,例如第一张表中的第 1 行。 Also the formula should only fill in a value if both columns match.此外,如果两列都匹配,公式应该只填写一个值。 All text combinations in both sheets are unique.两张表中的所有文本组合都是唯一的。

Is it possible to do this with text?是否可以用文字来做到这一点? Thank you for your help!谢谢您的帮助!

Try the following尝试以下

=ArrayFormula((IFERROR(VLOOKUP(R2:R&S2:S,{O2:O&P2:P,Q2:Q},2,0))&
               IFERROR(IF((R2:R<>"")*(S2:S<>""),VLOOKUP(R2:R&S2:S,{P2:P&O2:O,Q2:Q},2,0),""))))

(Do adjust locale and ranges according to your needs) (根据您的需要调整区域设置和范围)

在此处输入图像描述


Functions used:使用的功能:

If you can use two keys concated in the lookup table as a virtual key (ie make a key like "CAT|DOG"), then you can use that to look in the secondary table.如果您可以使用在查找表中连接的两个键作为虚拟键(即创建一个像“CAT|DOG”这样的键),那么您可以使用它在辅助表中查找。

If you can't guarantee the sort order of the two keys in the secondary table, you can use the following technique to "sort" the two keys so you can make a single lookup key that's always in one stable order.如果您不能保证辅助表中两个键的排序顺序,您可以使用以下技术对两个键进行“排序”,这样您就可以制作一个始终处于一个稳定顺序的查找键。

Sample Table样品表

A一个 B C C D D E SortedKey排序键
Cat Dog TRUE真的 Cat Dog CatDog猫狗
Dog Cat FALSE错误的 Cat Dog CatDog猫狗

Formulas公式

Sample formulas for row #1.第 1 行的示例公式。

  • For column C, use formula: =A1<B1对于列 C,使用公式: =A1<B1
  • For column D, use formula: =IF(C1=TRUE, A1, B1)对于 D 列,使用公式: =IF(C1=TRUE, A1, B1)
  • For column E, use formula: =IF(C1=TRUE, B1, A1)对于 E 列,使用公式: =IF(C1=TRUE, B1, A1)
  • For SortedKey, use formula: =concat(D1, E1)对于 SortedKey,使用公式: =concat(D1, E1)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 根据 Google 表格中的两列匹配返回第三列的值 - Return value of third column based on two column matches in Google Sheets 返回由第一列中的第一个搜索值和第二列中的第二个搜索值标识的第三列中的值 - Return the value from a third column identified by a first search value in the first column and a second search value in the second column 如果值与来自两个单独列的条件匹配,则对一列中的单元格求和 - Sum cells in one column, if values match criteria from two separate columns 如果两个单元格匹配/重复,则从秒返回并计算值 - If two cells match/duplicates, return and calculate value from second 匹配列中的单元格,然后从两个不同的选项卡中减去一个值 - Match Cells in column, then subtracting a value from two different tabs 在 2 个单元格中搜索名称,如果名称匹配,则返回第三个单元格中的值 - Search Name in 2 cells and return the value in third cell if the name matches 使用两列中的值在新列中返回特定值 - Use a value in two Columns to return a Particular Value in a New Column 查询工作表并返回连续匹配两个条件的列标题 - Query sheet and return Column Headers that match two criteria in a row Google Spreadsheet-根据不同的单元格内容填充单元格,并使用第三个单元格值 - Google Spreadsheet - Populate a cell based off different cells content, and use a third cells value 从下面的单元格中查找值并返回值 - Find a value and return values from cells below
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM