3

我正在为我的工作场所创建一个电子表格,可以找到我们使用的 LED 的驱动程序,但我遇到了一个小问题。我从另一张表中提取数据以使其变薄,然后我有一张用于公式的表,一张用于表格,以及它自己的表上的数据。出于某种原因,我在一张纸上进行计算,然后使用查询函数在另一张纸上返回该结果,但结果有时会丢失数据。

我正在使用这个公式来确定可以将多少个 LED 连接到驱动器:

=IF(A4="","",IF(U4="Y",If(K4>1,IF(round(O4)=round(P4),P4&" per Channel",O4&"-"&P4&" per Channel"),IF(round(O4)=round(P4),P4,O4)),IF(U4="Min+1",If(K4>1,IF(round(O4+1)=round(P4),P4&" per Channel",(O4+1)&"-"&P4&" per Channel"),IF(round(O4+1)=round(P4),P4,(O4+1)&"-"&P4)),IF(U4="Max-1",If(K4>1,IF(round(O4)=round(P4-1),O4&" per Channel",O4&"-"&(P4-1)&" per Channel"),IF(round(O4)=round(P4-1),P4,O4&"-"&(P4-1)))))))

然后我使用这个函数来显示所有可以工作的驱动程序的列表,但是前面公式的结果,即使它显示在公式表上,也不会显示在表单表上。

=IFERROR(if($C$3="Y",if(BFFormulas!R1="CC",query(BFFormulas!A3:Z900,"select A,B,D,H,I,K,Q,L where A != '' and J='Y' and N = 'Y' order by D ",1),if(BFFormulas!R1="CV",query(BFFormulas!A3:Z900,"select A,B,D,H,I,K,Q,L where V > "&BFFormulas!T1*D3&" and A != '' and J='Y' order by D ",1),"Missing Fixture Information")),if(BFFormulas!R1="CC",query(BFFormulas!A3:Z900,"select A,B,D,H,I,K,Q,L where A != '' and N = 'Y' order by D ",1),if(BFFormulas!R1="CV",query(BFFormulas!A3:Z900,"select A,B,D,H,I,K,Q,L where V > "&BFFormulas!T1*D3&" and A != '' order by D ",1),"Missing Fixture Information"))),"Could Not Find Fixture From This Source.")

谁能告诉我为什么会这样?

发生的事情的图片: https ://drive.google.com/file/d/0Bw6otjO0spyBd2NXYWhuQm1QbnM/view?usp=sharing

4

2 回答 2

2

QUERY 会将具有混合数据类型的列转换为一种数据类型。如果数据主要是数值,那么文本字符串(例如1-2在您的数据中)将被转换为空白单元格。

一种解决方法是将所有内容都转换为文本字符串(如果您可以接受其后果)。请注意&""附加到 QUERY 函数中的每个范围。

=ArrayFormula(IFERROR(if($C$3="Y",if(BFFormulas!R1="CC",query(BFFormulas!A3:Z900&"","select A,B,D,H,I,K,Q,L where A != '' and J='Y' and N = 'Y' order by D ",1),if(BFFormulas!R1="CV",query(BFFormulas!A3:Z900&"","select A,B,D,H,I,K,Q,L where V > "&BFFormulas!T1*D3&" and A != '' and J='Y' order by D ",1),"Missing Fixture Information")),if(BFFormulas!R1="CC",query(BFFormulas!A3:Z900&"","select A,B,D,H,I,K,Q,L where A != '' and N = 'Y' order by D ",1),if(BFFormulas!R1="CV",query(BFFormulas!A3:Z900&"","select A,B,D,H,I,K,Q,L where V > "&BFFormulas!T1*D3&" and A != '' order by D ",1),"Missing Fixture Information"))),"Could Not Find Fixture From This Source."))

于 2015-04-20T00:08:20.413 回答
2

另一个好的解决方案是将混合数据类型的列显式转换为带有TO_TEXT(). TO_TEXT()不能单独在QUERY()函数内部工作,但是由于您已经在使用ARRAYFORMULA(),因此将查询的范围包装在其中TO_TEXT()可能有助于解决问题。

TO_TEXT()将摆脱该范围内的标题值,因此QUERY(A:B, "SELECT B WHERE A = 'this one'")您需要使用虚拟列标题Col1而不是Col2. ARRAYFORUMLA(QUERY(TO_TEXT(A:B), "SELECT Col2 WHERE Col1 = 'this one'"))

资料来源:https ://infoinspired.com/google-docs/spreadsheet/mixed-data-type-issue-in-query/

于 2019-10-21T15:43:37.553 回答