简体   繁体   English

Google表格根据= QUERY结果进行条件格式设置

[英]Google sheets conditional formatting based on =QUERY result

I am trying to conditionally format a row in Google Sheets based on the result of a QUERY operation. 我正在尝试根据QUERY操作的结果在Google表格中有条件地设置行格式。 I can get the QUERY to return the value I want (either 0 or non-zero), however QUERY insists on returning a header row. 我可以让QUERY返回想要的值(0或非零),但是QUERY坚持返回标头行。

Since the QUERY now takes up 2 rows for every row of data, changing the format of the row based off the QUERY result starts to get weird after just a few rows. 由于QUERY现在每行数据占用2行,因此根据QUERY结果更改行格式仅在几行之后就变得很奇怪。

The problem I am ultimately trying to solve in the case where I enter a list of names, and I want to compare each name to a list of "NSF Names". 在输入名称列表的情况下,我最终想解决的问题是,我想将每个名称与“ NSF名称”列表进行比较。 If a name is entered, and it exists on the NSF list, I would like to flag the entry by highlighting the row red. 如果输入了一个名称,并且该名称存在于NSF列表中,我想通过突出显示红色行来标记该条目。

Help is greatly appreciated. 非常感谢您的帮助。

Edit: Formula, as requested: 编辑:公式,根据要求:

=query(A:D,"select count(A) where C contains '"&E1&"' and D contains '"&E2&"'")

A:D is the data set (A is a numeric ID, B is full name, C and D are first and last names respectively). A:D是数据集(A是数字ID,B是全名,C和D分别是名字和姓氏)。

E1 and E2 are placeholders for the person's first and last name, but would eventually be replaced with parsing the person's name, as it's inputted on the sheet (TRIM(LEFT(" ", A2) etc...) E1和E2是该人的名字和姓氏的占位符,但最终会被解析该人的名字所代替,因为它是在工作表上输入的(TRIM(LEFT(“”,A2)等。)

I can get the QUERY to return the value I want (either 0 or non-zero), however QUERY insists on returning a header row. 我可以让QUERY返回想要的值(0或非零),但是QUERY坚持返回标头行。

There might be better ways to achieve what you want to do, but in answer to this quote: 可能有更好的方法来实现您想要的目的,但是要回答此报价:

=QUERY(A:D,"select count(A) where C contains '"&E1&"' and D contains '"&E2&"' label count(A) ''")

查询似乎是一个漫长的过程( =countifs(C1:C7,E$1,D1:D7,E$2)可能就足够了),但可以通过将查询包装在以下标签中来剪掉标签:

 index(...,2)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM