I have 2 sheets
people sheet has
[company first_name last_name full_name address_line1 address_city address_state address_zip address_country telephone email order_id order_date order_time processor order_type order_currency commission campaign_id]
sales sheet has
[DATE PROSPECT NAME EMAIL ADDRESS CONTACT METHOD PRODUCT RESULT NOTES ]
How do I make the report to generate when people.email = sales.EMAIL ADDRESS and display the records only if they match (Not all of sales sheet)
Report fields are
full_name
EMAIL ADDRESS
PRODUCT
commission
Sample File
Please try to use basic formula for joining sheets + query to skip some rows.
Basic formula:
=FILTER({Sales!B14:B,Sales!C14:C,Sales!E14:E, vlookup(Sales!E14:E,{People!B2:B,People!D2:D},2,), Sales!F14:F},Sales!A14:A<>"")
The formula you need:
=QUERY(FILTER({Sales!B14:B,Sales!C14:C,Sales!E14:E, IFERROR(vlookup(Sales!E14:E,{People!B2:B,People!D2:D},2,), "do not show"), Sales!F14:F},Sales!A14:A<>""),"select * where Col4 <> 'do not show'")
How it works
It uses iferror(expression, "do not show") to replace #N/A error with the text "do not show".
Then it uses query to hide rows with value "do not show":
"select * where Col4 <> 'do not show'"
Basic formula and the question is here
Notes about usage:
Sales!B14:B,Sales!C14:C,Sales!E14:E are some columns you need to select first
IFERROR(vlookup(Sales!E14:E,{People!B2:B,People!D2:D},2,) will return column from "People", it is column People!D2:D. Please note that columns Sales!E14:E and People!B2:B are both containing a key, in the sample it is e-mail list.
Sales!F14:F is a column to return next.
filter condition Sales!A14:A<>"" is to skip empty rows from original sheet. You may also add other conditions into a filter.
query part will shorten the report and skip values where keys (emails) do not match. You may add other conditions into a query.
Note. Query language in Google Sheets does not have joins, and provided solution is a workaround. It shows how to make a join with a help of vlookup function in Sheets.
The provided formula gathers rows from sheet "Sales" and makes vlookup to sheet "People". You also may want to make vice-versa report: collect data from "People" and 'vlookup` data from "Sales".
"Vice-versa" report:
=QUERY(FILTER({vlookup(People!B2:B ,{Sales!E14:E, Sales!B14:B, Sales!C14:C, Sales!E14:E},{2, 3, 4},), People!B2:B, IFERROR(vlookup(People!B2:B ,{Sales!E14:E, Sales!F14:F},2,),100500)},People!A2:A<>""),"select * where Col5 <> 100500")
note! In this formula used numeric value 100500 to skip values because query works with the single data type (number or text).
Please comment here if you have any questions about how it works.
Related
I have a list of email addresses in one sheet (first column).
I have a list of transactions in another sheet with emails and sale amounts.
I am looking for a formula that adds up all the transaction $ sales for any transactions made by the people (emails) in the first sheet.
Any help would be much appreciated!
Your sample data is very limited (only one row matching one person, in fact). But the following formula should work for you. Place it in a new sheet, in cell A1:
=ArrayFormula(IFERROR({"Name","Total"; QUERY(FILTER(Transactions!A2:D,NOT(ISERROR(VLOOKUP(Transactions!A2:A,Tags!A:A,1,FALSE)))),"Select Col2, SUM(Col4) GROUP BY Col2 ORDER BY Col2 LABEL SUM(Col4) '' ")},"No Data"))
This one formula will produce the headers (which you can change within the formula itself as desired) and all results.
FILTER filters in only 'Transactions' data (names through amounts) where the emails are found in the 'Tags' sheet.
Then QUERY returns the name and totals for each match in alphabetical order by name.
If there are no matches, "No Data" will show instead.
If I understood your question correctly!
Try this on the sheet, where you only have emails and wanted to get sum of sales amount
=sumifs(range_whichHasTransaction , range_of_Email_inThat_TransactionsTable , Cell_Reference_ofEmail_forWhich_you_want_sum_the_Transaction_Amount)
it will Look something like this:-
sumifs(TransactionSheet!B:B,TransactionSheet!A:A,Emails!A2)
Reference
SUMIFS
I am trying to find a way to see which employees are not working between 2 dates.
Should I use vlookup, index & match, filter, query, or something else?
Sheet 1 contains employee details & start/end dates.
Sheet 2 accepts user input to select 2 dates, and it will automatically display a list of available employees who are not working.
Sheet 1 - Database/Log of all employees and days worked.
#
A
B
C
D
1
ID
Name
Start Date
End Date
2
12345
John
01/01/2021
01/08/2021
3
54321
Sarah
01/24/2021
01/29/2021
4
00731
James
02/05/2021
02/15/2021
5
00731
John
02/10/2021
02/30/2021
Sheet 2 (Row 1-2)- Manually enter in two dates.
#
A
B
1
Start Date (Manual input)
End Date (Manual input)
2
01/01/2021
01/30/2021
Sheet 2 (Row 3+)- List of all employees that are not working between the two dates entered in Sheet 2!A2:B2 (Expected Results)
#
A
B
3
ID
Name
4
00731
James
try:
=INDEX(SUBSTITUTE(UNIQUE(QUERY(""&SPLIT(FLATTEN(IF(SEQUENCE(1, MAX(D2:D-C2:C))<=D2:D-C2:C,
"♥"&A2:A&"♦"&B2:B&"♦"&C2:C+SEQUENCE(1, MAX(D2:D-C2:C), 0), )), "♦"),
"select Col1,Col2 where not Col3 matches '"&JOIN("|", "^$",
IF(SEQUENCE(1, G2-F2)<=G2-F2, F2+SEQUENCE(1, G2-F2, 0), ))&"'", 0)), "♥", ))
demo sheet
Assuming the name of your first sheet with the full data is actually Sheet1, place the following in Sheet2 cell A4:
=FILTER(Sheet1!A2:B,Sheet1!A2:A<>"",(Sheet1!C2:C>G2)+(Sheet1!D2:D<F2))
The combined either/or condition (Sheet1!C2:C>G2)+(Sheet1!D2:D<F2) in the FILTER means "either the start date is after the range date given, or the end date is before the range date given."
The other condition of Sheet1!A2:A<>"" just rules out blank rows in the original data set. It's not strictly necessary as far as the visual results are concerned; but it keeps null rows from being added to those results, which would allow you to enter data below the results in Col A and B of Sheet2 if you wanted, or to have fewer rows in Sheet2 than in Sheet1 without the formula adding more rows to accommodate null returns.
Your posted sample data is unclear. You have two different names for the same ID (i.e., 00731). And you have an "End Date" in D5 of February 30, 2021—which is not a valid date. In any case, it's unclear whether the same person/ID may turn up twice in the original data set. My formula above assumes you will not.
If your original data list may, in fact, contain duplicates, things get a bit trickier. In that case, use the following formula instead, in Sheet2 cell A4:
=UNIQUE(FILTER(A2:B,ISERROR(VLOOKUP(A2:A,FILTER(A2:A,((C2:C>=F2)*(C2:C<=G2))+((D2:D>=F2)*(D2:D<=G2))),1,FALSE))))
Here, the inner FILTER first forms a list of all people who are working during that range, and then the outer FILTER filters in a UNIQUE set of the people who are not on that inner list (i.e., trying to VLOOKUP them returns IS(an)ERROR).
This is a copy of another excel sheet I'm working on, this is the query I've:
=query(indirect("'"&VLOOKUP(C6,BANK_CARDS!$B$2:$F$4,5, false)&"'!$B$3:K"), "select sum(J) where F='"&$H6&"' and G='"&I6&"' and H="&C6&" and month(C)+1="&month(today())&" label sum(J)''",0)
This part, gets the cell value to get the name of the credit card which we'll be getting the data transactions:
indirect("'"&VLOOKUP(C6,BANK_CARDS!$B$2:$F$4,5, false)&"'!$B$3:K")
This should return the sum of the quantity in J based on the other conditions (on the same month, same credit card number, category and subcategory).
"select sum(J) where F='"&$H6&"' and G='"&I6&"' and H="&C6&" and month(C)+1="&month(today())&" label sum(J)''"
I don't know how to fix or improve this, here is the link of the google-sheet.
https://docs.google.com/spreadsheets/d/1iAJrF7syT8TBz1emKnnioQvZs7Z-5q5koYLGA419rOs/edit?usp=sharing
Your Bank Id column values were formatted as text, thus the query parameter has to be in text format as well:
=query(indirect("'"&VLOOKUP(C6,BANK_CARDS!$B$2:$F$4,5, false)&"'!$B$3:K"), "select sum(J) where F='"&$H6&"' and G='"&I6&"' and H='"&C6&"' and month(C)+1="&month(today())&" label sum(J)''",0)
This one in particular: H='"&C6&"'
From your test sheet it now displays:
I am trying to build a Query to sort through different staff training reports. I am able to display all "Completed" certifications from staff, however, I would also like the query to be dynamic, and only display data, if it matches the name, entered into the "search key" cell so that individual staff can be viewed.
I've tried using this formula,
=query(Data!A1:E50,select A,B,C,D,E where E="Completed" and A='"&$B$2&"',0")")
however, it returns #ERROR!. In this case, B2 would be the search box where you can select the Staff's name.
Here's a link.
https://docs.google.com/spreadsheets/d/1ePKb2pg3QJeCmw5bf-4Rgg67PGLV7PARKCko4P_uTKQ/edit#gid=707448770
Any help?
correct syntax would be:
=QUERY(Data!A1:E19, "select A,B,C,D,E where E='Completed' and A='"&$B$1&"'", 0)
for caps insensitive search it would be:
=QUERY(Data!A1:E19, "select A,B,C,D,E where E='Completed' and lower(A)='"&LOWER(B1)&"'", 0)
I am trying to use the QUERY function on a list of Google Form responses to only display the most recent of unique entries(based on the key Student ID).
A = Timestamp Column
C = Student ID Column
Using:
select max(A)
group by C
I was able to get the right entries, but only one column for each(I want all the data, the whole row, from the right entries)
So I tried using:
select max(A),B,C,D,E,F,G,H
group by C
But this gives an error
Unable to parse query string for Function QUERY parameter 2:
ADD_COL_TO_GROUP_BY_OR_AGGB
I am new to databases, first time using QUERY. Sorry if this is confusing, but maybe the sheet makes more sense:
spreadsheet
In addition to Chris' contribution and using QUERY():
=ArrayFormula(vlookup(query({row(Raw!A:A),sort(Raw!A:J)},
"select max(Col1) where Col4 is not null group by Col4 label max(Col1)''",0),
{row(Raw!A:A),sort(Raw!A:J)},{2,3,4,5,6,7,8,9,10,11},1))
Does this formula work as you want:
={Raw!A1:J1;FILTER(Raw!A2:J,MMULT((Raw!C2:C=TRANSPOSE(Raw!C2:C))*(Raw!A2:A<TRANSPOSE(Raw!A2:A)),SIGN(ROW(Raw!A2:A)))=0)}