Querying, Ordering, and Selecting from a Row by String Value Across Sheets - google-sheets

I have a Google Sheet file called Shipments that contains shipments delivered to different warehouses, with fields Delivery Date - Company Name - Shipment Type, and I have a sheet called Companies which has a columns Company Name - Membership Status - Rating. All of these values are pulled automatically from a different GSheet, they are not entered manually, so row orders change.
I want to pull the last shipment delivered for a company in the Shipments sheet into a "Last Delivery Date" field in the Companies sheet, so the Companies sheet has the following columns:
Company Name - Membership Status - Rating - Last Delivery
I think I have to do a query or a named range that is something along the lines of SELECT ONE Delivery Date WHERE B (column for company name in Shipments) === A (column for company name in Companies) ORDER BY (last delivery date column) DESCENDING
Not sure how to accomplish this in GSheets, am exploring queries now. Any help greatly appreciated!

You can use this in Companies!D1:
={
"Last Delivery";
ARRAYFORMULA(
IFNA(VLOOKUP(
Companies!A2:A,
SORT({Shipments!B2:B, Shipments!A2:A}, 2, FALSE),
2,
0
))
)
}
Assuming Company Name is in Companies!A:A and in Shipments!B:B, Delivery Date is in Shipments!A:A.
Maybe there is a more elegant solution that uses QUERY. Could not come up with one on the spot.

Related

Google Sheets -- Search Employee Name from Sheet 1, in Sheet 2. If exists take value of employee number and write as comment

Spreadsheets:
Full Employee List
Offer Tracker List
Look at a list of names in the Full Employee List and see if there is a match in the Offer Tracker List.
If there is a match, I want to pull the value that is in column C (employee number) and write it as a comment in the Full Employee List Column R.
In the Offer Tracker Sheet the Name is in Column F, and the employee number is in Column C
In the Full Employee List sheet the Name is in Column D and I would need to write the employee number in column R, in the same row the name is listed.
I do not have edit access in the Full Employee sheet, so I basically need to put a comment of the employee number so that someone else can write it in officially (facepalm). Therefore, if I can do this via a script that would be great -- or if that sounds like over-engineering I can try to lobby for edit access and maybe there is a much simpler way of doing this via a formula ?

Google Sheets query + array + sort + transpose?

I'm working on a dynamic dashboard in Google Sheets that uses response validation to choose an student's name from a drop-down, pulling the relevant information for that particular student and adjusting the graphs/charts. One of the sections of the dashboard shows a list of events and the dates they happened, in chronological order. The order of events changes based on the order the dates happened in, which are pulling from a separate sheet (called "Database"), meaning the order of the events changes for each student.
I'm trying to create a formula that will locate the row for the currently selected student in the Database sheet, create an array with the headers of the Database sheet (for the event names) and the one row that matches the selected student's name, put that array in order by chronological date, and then transposes it so that it's a list of events in one column and their date in the other column.
I've created a copy of the dashboard and removed/edited all student information. In the sheet called "Student Tracker", I'm working in cell J7 (colored purple). It needs to pull the dates for the selected student and the header row (to label the dates) from the sheet called "studentList".
Thanks in advance for any help you can provide!
try:
=QUERY(TRANSPOSE(QUERY(studentList!A:Q,
"select E,F,G,H,I,J,K,L,M,N,O,P,Q
where A ='"&C4&"'", 1)),
"select Col1,' ',Col2
where Col2 is not null
order by Col2 label ' '''", 0)
note that columns J and K are merged so one empty column needed to be included in outer QUERY

How to join tables using Query or Vlookup

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.

VLOOKUP not looking the correct information up

I have a table in google sheets with 4 sheets in the same table. the details table contains the student ID, first name and second name but I would like to lookup the scanned number from the attendance table however the student number needs to match the scanned number.
the student number and the scanned number are both in the attendance table but I would like the scanned number to go into the details table according to the matched student number.
I have tried the following VLOOKUP but I am just getting errors.
=ArrayFormula(IF(LEN(B2:B), VLOOKUP(B2:B,'Student Attendance'!A:F,2,FALSE),))
so in sheet 1 I have scanned number in column B and Student number in column D which is entered through an app. on sheet 2 i have already got the student ID but i would like to lookup the scanned number from sheet 1 and enter accordingly against the correct student ID
I have tried using:
=IFERROR(VLOOKUP(B3:B,'Student Attendance'!A:F,2,TRUE),)
however this is only printing the same scanned number for every unique student number entered.
example data:
attendance sheet:
timestamp, scanned number, class, student number
time/date BARCODE-SCANNED Subject 123456
time/date BARCODE-SCANNED1 Subject 621314
this is all entered through an app so nothing manual here.
details sheet:
scanned number, student number, name
BARCODE-SCANNED 123456 Student name
BARCODE-SCANNED1 621314 Student name
on this sheet the student number and the name is already inputted manually but i would like to get the scanned number from the first sheet according to the student number. at the moment i have only got student number and name in this sheet.
Try
=ARRAYFORMULA (IFERROR(VLOOKUP(B3:B,{'Student Attendance'!D:D, 'Student Attendance'!B:B},2,TRUE),))
The vlookup value should always be in the first column of the lookup range.

Multiple criteria in a filter/summation combined, entered into two columns for sorting

I have a spreadsheet that tallies sales over time, including sales person, office they work out of, and the price of whatever it is that they sold. I am attempting to create a two-column filtered list by multiple criteria. The data looks like this:
Date Name Office Price
5/5/12 Joe OW 220000
6/1/12 Jim SOL 100000
What I want to be able to do is create a two-column entry that sums the price column, but uses multiple critera from the first three to do so. For instance, "everyone named Jim who sold something in May", and then I'd like to sort that by the top three.
Using items like:
=FILTER( C1:C ; D1:D="OW"; month(B1:B)=month("5/12/12"))
and
=ARRAYFORMULA(frequency(MATCH(E1:E&counta(E1:E),UNIQUE(E1:E&counta(E1:E)),0), MATCH(UNIQUE(E1:E&counta(E1:E)),UNIQUE(E1:E&counta(E1:E)),0)))
I can filter and tally, but I am unable to replace the frequency mentioned above with a summation of the price column.
Rather than using FILTER you could put together something using SUMPRODUCT:
=arrayformula(sumproduct($E$2:$E$3*($C$2:$C$3=C2)))
If you have column E as price and column C as name, this creates a new column that shows the total earnings for each name, next to every instance where that name appears in the array. You can apply further conditions within the SUMPRODUCT call as needed. You could then apply UNIQUE to deduplicate and sort the resulting table to see the top 3.

Resources