[英]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 -
我有一张看起来与此类似的表-
And another that looks like this -另一个看起来像这样 -
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.如果您不能保证辅助表中两个键的排序顺序,您可以使用以下技术对两个键进行“排序”,这样您就可以制作一个始终处于一个稳定顺序的查找键。
A![]() |
B![]() |
C ![]() |
D ![]() |
E![]() |
SortedKey![]() |
---|---|---|---|---|---|
Cat![]() |
Dog![]() |
TRUE![]() |
Cat![]() |
Dog![]() |
CatDog![]() |
Dog![]() |
Cat![]() |
FALSE![]() |
Cat![]() |
Dog![]() |
CatDog![]() |
Sample formulas for row #1.第 1 行的示例公式。
=A1<B1
=A1<B1
=IF(C1=TRUE, A1, B1)
=IF(C1=TRUE, A1, B1)
=IF(C1=TRUE, B1, A1)
=IF(C1=TRUE, B1, A1)
=concat(D1, E1)
=concat(D1, E1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.