Select 'x' returns "x"() - google-sheets

I want to return 3 columns, A(description), 'D'(hard coded value of D), Q(date)
=query('Detailed Plan'!$A$2:$Q, "select A,'D',Q where D = date)
It returns the following results. Rows 2 and greater are exactly what I want and would be perfect if I didn't get the first row. How do I get a hard coded value into a column without "D"() showing up in the first row?
blank, "D"(), blank
Description, D, date
Description, D, date
Description, D, date
Thanks so much for any help that is provided.

You can use 'label' in the query string.
=query('Detailed Plan'!$A$2:$Q, "select A, D, Q where D = date label A 'Description', D 'Some value', Q 'Date' ", 0)
EDIT: if you don't need headers at all, try
=query('Detailed Plan'!$A$2:$Q, "select A, D, Q where D = date ", 0)

Related

Google sheet text formula not working; query by date and text() not working

[![enter image description here][1]][1]
So I am trying to pull a query by date, but when I do exactly like the tutorials I found on the internet it just doesn't work,
i.e. :
=QUERY(Penjualan!$A$1:$H$136,"select A , B , D , H where B > date '"&TEXT(TODAY(),"yyyy-mm-dd")&"'",1)
or
=QUERY(Penjualan!A1:H; "select A , B , D , H where B = date '"&text(D1, "yyyy-mm-dd")&"'" )
does anyone know what is wrong?
try like this:
=TEXT(TODAY(); "yyyy-mm-dd")
=QUERY(Penjualan!A1:H;
"select A,B,D,H where B = date '"&TEXT(D1; "yyyy-mm-dd")&"'")
=QUERY(Penjualan!A1:H;
"select A,B,D,H where B > date '"&TEXT(TODAY(); "yyyy-mm-dd")&"'"; 1)

Google Sheet IFS combine with FILTER Function

I have the following Google Seet Table
Old New New2
W01
W02 W04
W03 W05 W06
I want to create a formular that transforms the table to this one
Old New
W02 W04
W03 W05
W05 W06
So any time a switch from Old to New or New to New2 happens should be displayed.
I wrote the following formular but i always get an error:
= IFS(B1 = "";""; AND(NOT(B1 = ""); NICHT(C1 = ""));FILTER({A1\ B1}; NICHT(A1=""));NICHT(B1 = "");FILTER({B1\ C1}; NICHT(B1="")))
Has anybody an idea?
Concatenate the results of two Query calls:
={
QUERY(A1:B4,
"select A,B where B<>''");
QUERY(B1:C4,
"select B,C where C<>'' label B '', C ''", 1)
}
or in German locale:
={
QUERY(A1:B4;
"select A,B where B<>''");
QUERY(B1:C4;
"select B,C where C<>'' label B '', C ''"; 1)
}
The label statements in the second query are necessary to suppress the column labels since you want to treat certain columns in New1 as Old.

Pass a Date value from a cell in Google Sheet formula

How do I re write this query for Google sheet, so that the dates in column B can be taken from a cell say X1 and X2
=QUERY(master!A:N,"select B,D,H where B>=date '2021-10-01' and B<=date '2021-10-31' and (E='3-MonoYarnSupply' or E='4-MultiYarnSupply') label B 'Date',D 'Particulars',H 'Quantity Supplied'")
Expected formula
=QUERY(master!A:N,"select B,D,H where B>X1 and B<=X2 and (E='3-MonoYarnSupply' or E='4-MultiYarnSupply') label B 'Date',D 'Particulars',H 'Quantity Supplied'")
Where X1 = 01-10-2021 and X2 = 31-10-2021
You can split the formula and use string concatenation logic to refer to other cells like this:
=QUERY(A:N,"select B,D,H where B>=date '" & TEXT(X1, "YYY-MM-DD") & "' and B<=date '" & TEXT(X2, "YYY-MM-DD") & "' and (E='3-MonoYarnSupply' or E='4-MultiYarnSupply') label B 'Date',D 'Particulars',H 'Quantity Supplied'")
B >= date '"&TEXT(X1,"yyyy-mm-dd")&"' and B <= date '"&TEXT(X3,"yyyy-mm-dd")&"'
Thank you #Gangula. Qualifying the date values as above in the query helped to achieve what I required. Thank you for your time.

Google Sheets Two Lists as Criteria for Query

I have the following query which is working fine. However I'd like to adde some additional logic if possible where if the there is a value in K3 then ideally the query would not use WHERE R = '"&$K2&"' in the query below but rather use WHERE D = '"&$K3&"'.
Here is a sample sheet. https://docs.google.com/spreadsheets/d/1Lt0RzwtuqIrxWYmWnYK4nh0JN2WdM0icpYF9oXGRfB8/edit?usp=sharing
QUERY(Transactions,"SELECT C,D,B,E WHERE R = '"&$K2&"' AND B > date '"&TEXT($C$2,"yyyy-mm-dd")&"' AND B <= date '"&TEXT($C$3,"yyyy-mm-dd")&"'
",1)
Try
=QUERY(Transactions,"SELECT C,D,B,E WHERE "&if(K3="",L2,L3)&" = '"&if(K3="",K2,K3)&"' AND B > date '"&TEXT($C$2,"yyyy-mm-dd")&"' AND B <= date '"&TEXT($C$3,"yyyy-mm-dd")&"' ",1)
with R and D in L2/L3

Creating a query that will filter based on multiple criteria from dropdown menus in Google Sheets

I am trying to create a dashboard that will filter data based on multiple criteria.
Here is a copy of the spreadsheet: https://docs.google.com/spreadsheets/d/1sJcsu0VpnLBi7wh4l-NEFdYfkxWgC6vpX8AeN9u-KlQ/edit?usp=sharing
I am having a hard time getting the query to work as I want.
I have created data validation cells for several search criteria (Name, reporter, incident type, location, start date, end date).
There are four columns for student names, based on the way the form is set up. I am able to get it to filter based on the student name using this formula: =QUERY('Form Data'!$A$2:M,"Select * where B = '"&E1&"' OR C = '"&E1&"' OR D = '"&E1&"' OR E = '"&E1&"'",0)
When I try to add other criteria, the formula breaks down. I've tried:
Select * where B = '"&E1&"' OR C = '"&E1&"' OR D = '"&E1&"' OR E = '"&E1&"' AND D >= Date '"&B11&"' AND A <= Date '"&B12&"' to try and filter date, but I'm getting an error. It says the date format isn't correct, but it's formatted yyyy/MM/dd as it says it should be.
I also tried: =QUERY('Form Data'!$A$2:M,"Select * where B = '"&E1&"' OR C = '"&E1&"' OR D = '"&E1&"' OR E = '"&E1&"'" &if(B5="All",,"'"&B5&"'"),0); this works when "All" is selected, but not when I pick another name from the drop down list.
Any help would be enormously appreciated
try:
=QUERY('Form Data'!A2:M,
"where (B = '"&E1&"'
or C = '"&E1&"'
or D = '"&E1&"'
or E = '"&E1&"')
and A >= date '"&TEXT(B11, "yyyy-mm-dd")&"'
and A <= date '"&TEXT(B12, "yyyy-mm-dd")&"'", 0)

Resources