Google sheet Query Function Returns blank result from cell with data

Aaron Effinger picture Aaron Effinger · Apr 19, 2015 · Viewed 12.2k times · Source

I am creating a spreadsheet for my work place that will find drivers for the LED's we use but I've run into a slight problem. i pull in the data from another sheet to thin it out, i then have a sheet for formulas, one for the form, and the data on its own sheet. for some reason, i do a calculation on one sheet, then use the query function to return that result on another sheet, but the result sometimes misses data.

I am using this formula to determine how many LED's can be attached to the driver:

=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)))))))

I then use this function to display a list of all the drivers that will work, but the result of the previous formula, even though it displays on the formulas sheet, will not display on the forms sheet.

=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.")

Can anyone tell me why this is happening?

Image of what happening: https://drive.google.com/file/d/0Bw6otjO0spyBd2NXYWhuQm1QbnM/view?usp=sharing

Answer

AdamL picture AdamL · Apr 20, 2015

QUERY will convert columns with mixed data types into one data type. If the data is mostly numerical values, then text strings (eg 1-2 in your data) will be converted to blank cells.

A workaround is to convert everything to text strings (if the consequences of that are acceptable to you). Note the &"" appended to each range in the QUERY functions.

=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."))