I need to combine 3 sets of data vertically, using a Query. The first 2 data sources ('SOURCE 1'!A:T and EG:EZ) have the same conditions and I was able to combine them with no problem, but the 3rd data source ('SOURCE 3'!A:T) has different conditions and when I add this source I result in an error. The column headers will be identical in the output.
This is the formula containing ONLY the first 2 data sources, that works:
=QUERY({'SOURCE 1'!A:T;EG:EZ},"Select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 where Col10 >= date '"&TEXT(B1,"yyyy-mm-dd")&"' and Col10 <= date '"&TEXT(D1,"yyyy-mm-dd")&"' and Col20 = 'YES' and Col1 starts with 'APP-' order by Col2,Col10,Col1,Col9 label Col11 'NAME'",1)
When adding in the 3rd data source, below are the 3 formulas I've tried, but all result in the error:
In ARRAY_LITERAL, an Array Literal was missing values for one or more rows.
Attempt 1:
={QUERY({'SOURCE 1'!A:T;EG:EZ},"Select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 where Col10 >= date '"&TEXT(B1,"yyyy-mm-dd")&"' and Col10 <= date '"&TEXT(D1,"yyyy-mm-dd")&"' and Col20 = 'YES' and Col1 starts with 'APP-' order by Col2,Col10,Col1,Col9 label Col11 'NAME'",1);
QUERY('SOURCE 3'!A:T,"Select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 where Col1 is not null")}
Attempt 2:
={QUERY('SOURCE 1'!A:T,"Select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 where Col10 >= date '"&TEXT(B1,"yyyy-mm-dd")&"' and Col10 <= date '"&TEXT(D1,"yyyy-mm-dd")&"' and Col20 = 'YES' and Col1 starts with 'APP-' order by Col2,Col10,Col1,Col9 label Col11 'NAME'",1);
QUERY(EG:EZ,"Select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 where Col10 >= date '"&TEXT(B1,"yyyy-mm-dd")&"' and Col10 <= date '"&TEXT(D1,"yyyy-mm-dd")&"' and Col20 = 'YES' and Col1 starts with 'APP-' order by Col2,Col10,Col1,Col9 label Col11 'NAME'");
QUERY('SOURCE 3'!A:T,"Select Col1,Col2,Col3,Col4,Col5,Col16,' ',Col8,Col9,Col10,Col11,Col12,Col13 where Col1 is not null")}
Attempt 3:
={QUERY('SOURCE 1'!A:T,"Select A,B,C,D,E,F,G,H,I,J,K,L,M where J >= date '"&TEXT(B1,"yyyy-mm-dd")&"' and J <= date '"&TEXT(D1,"yyyy-mm-dd")&"' and T = 'YES' and A starts with 'APP-' order by B,J,A,I label K 'NAME'",1);
QUERY(EG:EZ,"Select A,B,C,D,E,F,G,H,I,J,K,L,M where J >= date '"&TEXT(B1,"yyyy-mm-dd")&"' and J <= date '"&TEXT(D1,"yyyy-mm-dd")&"' and T = 'YES' and A starts with 'APP-' order by B,J,A,I");
QUERY('SOURCE 3'!A:T,"Select A,B,C,D,E,P,' ',H,I,J,K,L,M where A is not null")}
Any advice would be much appreciated. Thank you!
If you write QUERY(EG:EZ,"Select A,B,C,D,E,F,G,H,I,J,K,L,M you can't select A... within EG:EZ!
I suggest to change 'SOURCE 1'!A:T by {'SOURCE 1'!A:T} , idem for EG:EZ and then you will be able to use only Col1, Col2 etc. in your formula.
Try
={QUERY({'SOURCE 1'!A:T},"Select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 where Col10 >= date '"&TEXT(B1,"yyyy-mm-dd")&"' and Col10 <= date '"&TEXT(D1,"yyyy-mm-dd")&"' and Col20 = 'YES' and Col1 starts with 'APP-' order by Col2,Col10,Col1,Col9 label Col11 'NAME'",1);
QUERY({EG:EZ},"Select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 where Col10 >= date '"&TEXT(B1,"yyyy-mm-dd")&"' and Col10 <= date '"&TEXT(D1,"yyyy-mm-dd")&"' and Col20 = 'YES' and Col1 starts with 'APP-' order by Col2,Col10,Col1,Col9 label Col11 'NAME'");
QUERY({'SOURCE 3'!A:T},"Select Col1,Col2,Col3,Col4,Col5,Col16,' ',Col8,Col9,Col10,Col11,Col12,Col13 where Col1 is not null")}
if there is a lack of data in one of the three queries, you will also get an error, in that case, add iferror(query______,{"","","",...} on each query
This formula is returning eveything right,but the phone numbers, which are preceded by an apostrophe. If I happen to delete the apostrophe, it displays the numbers, but since there may be a 0 at the beginning, it has to come as text.
Here's the formula:
=iferror(QUERY('Form Responses'!$A$4:$P; "select N, B, C, D, E, F, G, H, I, J, K, L, A where N >= 1 and todate(A)=date '"&TEXT(B3;"yyyy-mm-dd")&"' order by N Asc");"Pick a date")
Here's how the data looks:
...and this is the result right now:
Here's the link to an example:
https://docs.google.com/spreadsheets/d/1vxCwfcXRrpuvmkhpRsFrKQSq5aMjkdqlUYY-6_UknuE/edit?usp=sharing
Appreciate your time/help - as usual!
try:
=INDEX(SUBSTITUTE(IFERROR(QUERY(
{'Form Responses'!A4:P\ TEXT('Form Responses'!E4:E; "\×0")};
"select Col14,Col2,Col3,Col4,Col17,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col1
where Col14 >= 1
and todate(Col1) = date '"&TEXT(B3; "yyyy-mm-dd")&"'
order by Col14 asc"); "Pick a date"); "×"; ))
update:
try:
=ARRAYFORMULA(TEXT(SUBSTITUTE(IFERROR(QUERY(
{'Form Responses'!A4:P\ TEXT('Form Responses'!E4:E; "\×0")};
"select Col14,Col2,Col3,Col4,Col17,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col1
where Col14 >= 1
and todate(Col1) = date '"&TEXT(B3; "yyyy-mm-dd")&"'
order by Col14 asc"); "Pick a date"); "×"; );
{"#"\"#"\"#"\"#"\"\0#"\"#"\"#"\"#"\"#"\"#"\"#"\"#"\"mm/dd/yyyy"}))
I have two datasets:
1) The number of days passed since the product was released
2) Total Number of Positive Reviews
What I am trying to archive is a 1-100 score, since the product that was released one year ago and has +1000 positive reviews is not the same with a product that was released a 1-2 month ago and already has +300 positive reviews. In a nutshell, depending on "days passed till now" - the value of "total amount of positive reviews" should drop giving 1-100 rating to filter out the most valuable products.
I'm not even sure how to approach this problem, please help me out.
There would be around 1000 products that I'd need to score, so I thought there might be a predefined formula for this in Google Sheets.
Example: https://docs.google.com/spreadsheets/d/1Y3q7URy5s8B5x3HVIzjaDzIZN3FRRvoduJAXobw1UOk/edit#gid=1382498268
this will filter out all products with:
1000+ reviews if older than 356 days
300+ reviews if not older than 60 days
={A1:D1; QUERY(
{IFERROR(QUERY(A2:D, "select * where D >= 1000 and C > 365", 0), {"","","",""});
IFERROR(QUERY(A2:D, "select * where D >= 300 and C < 60 ", 0), {"","","",""})},
"select * order by Col4 desc", 0)}
if you still want that "score" column use this:
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A,
{{QUERY(A2:D, "select A where C >= 365 order by D desc", 0),
ROW(INDIRECT("A1:A"&COUNTA(
QUERY(A2:D, "select A where C >= 365 order by D", 0))))};
{QUERY(A2:D, "select A where C < 365 and C > 0 order by D desc", 0),
ROW(INDIRECT("A1:A"&COUNTA(
QUERY(A2:D, "select A where C < 365 and C > 0 order by D", 0))))}},
2, 0), ))
if you want no more then 100 use:
=ARRAYFORMULA(IF(IFERROR(VLOOKUP(A2:A,
{{QUERY(A2:D, "select A where C >= 365 order by D desc", 0),
ROW(INDIRECT("A1:A"&COUNTA(
QUERY(A2:D, "select A where C >= 365 order by D", 0))))};
{QUERY(A2:D, "select A where C < 365 and C > 0 order by D desc", 0),
ROW(INDIRECT("A1:A"&COUNTA(
QUERY(A2:D, "select A where C < 365 and C > 0 order by D", 0))))}},
2, 0), )>100, ,
IFERROR(VLOOKUP(A2:A,
{{QUERY(A2:D, "select A where C >= 365 order by D desc", 0),
ROW(INDIRECT("A1:A"&COUNTA(
QUERY(A2:D, "select A where C >= 365 order by D", 0))))};
{QUERY(A2:D, "select A where C < 365 and C > 0 order by D desc", 0),
ROW(INDIRECT("A1:A"&COUNTA(
QUERY(A2:D, "select A where C < 365 and C > 0 order by D", 0))))}},
2, 0), )))