查询以基于多个条件从不同列检索值

问题描述 投票:1回答:1

我需要创建一个QUERY函数来根据以下2个条件从不同的列中检索值:

如果A列中的值是“公司名称已更改”,则需要列B和C.如果A列中的值为“电子邮件已更改”,则需要从列B,C,D中检索该记录的相应值和E.以上所有在同一张表中。

请原谅我没有分享虚拟表格,但我有公司安全限制,这不允许我向公司外的任何人显示任何表格。

来源标签:

+----------------------+------+-------------+--------------------------+----------------------------+
|           A          |   B  |      C      |             D            |              E             |
+----------------------+------+-------------+--------------------------+----------------------------+
| Status               | ID   | Company     | Email                    | Generic Email              |
+----------------------+------+-------------+--------------------------+----------------------------+
| Email changed        | 223A | ABC Capital | [email protected]    | [email protected]        |
+----------------------+------+-------------+--------------------------+----------------------------+
| In progress          | 446g | DEF Finance | [email protected] | [email protected] |
+----------------------+------+-------------+--------------------------+----------------------------+
| Company name changed | 233A | GHI Dealing | [email protected]    | [email protected]      |
+----------------------+------+-------------+--------------------------+----------------------------+
| Dissolved            | 334s | JKL Brokers | [email protected]       | [email protected]         |
+----------------------+------+-------------+--------------------------+----------------------------+

输出标签:

+------+-------------+-----------------------+---------------------+
| ID   | Company     | Email                 | Generic Email       |
+------+-------------+-----------------------+---------------------+
| 223A | ABC Capital | [email protected] | [email protected] |
+------+-------------+-----------------------+---------------------+
| 233A | GHI Dealing |                       |                     |
+------+-------------+-----------------------+---------------------+

可能的解决办法是什么?

google-sheets google-sheets-formula google-sheets-query
1个回答
1
投票
={QUERY(A1:E, "select B, C, D, E 
               where A = 'Email changed'", 1);
  QUERY(A2:E, "select B, C, ' ', '  ' 
               where A = 'Company name changed'
               label ' ''', '  '''", 0)}

0

© www.soinside.com 2019 - 2024. All rights reserved.