Excel Count and Multiply cells between sheets - google-sheets

I have 2 sheets, Sheet 1 and Sheet 2.
In Sheet 1 is a list of Vacancies in one cell and next to it is the Name of the person who has those Vacancies.
In Sheet 2 I am trying to find the TOTAL amount of Vacancies that each person listed has using a Formula
=COUNTIF(Sheet1!B:B,A2)
The only problem is that it needs to count in Sheet 1 how many vacancies a specific person has.
eg: it shows John has 3 vacancies when he should have 11.
Added a SUMIF attempt

The issue is that you should use SUMIF() instead of COUNTIF() as per the comments above, though since you are not using Excel but Google Spreadsheets, this opens up other options (note, the two look alike but are actually very different).
You could try utilize QUERY():
Formula in D1:
=QUERY(A1:B,"Select B, Sum(A) where A is not null group by B label Sum(A) 'Total Vacancies'")

Related

Google Sheets: Dynamic lookup across two (merged) sheets

I have two external GSheets that are set up as room bookings with a running date in col B and the different rooms ppl can book in col C-AX for Sheet1, C-X for Sheet2, as well as my own Sheet with a list of names (let's call it NameSheet).
Example:
Goal: I want to add an extra column in NameSheet that returns all dates within the next two weeks in which a person has booked a room as well as the room info. Like this:
I used IMPORTRANGE to import both Sheets into my own Sheet (Merged_Sheet) and then merge them dynamically using a simple query formula:
=QUERY({'Sheet1'!A:AX;'Sheet2'!A:AX},"select * where Col1 <>''")
(I had to expand Sheet 2 to AX in order to merge them.)
I then set up another sheet (Date_Filter) to dynamically filter on the next two weeks:
=filter('Merged_Sheet'!A:AX,'Merged_Sheet'!B:B<=today()+7*1)
Finally, I have so far only managed to add a column in my original NameSheet that counts the number of times a there is a partial match on a name in the Merged_Sheet:
=countif(Date_Filter!A:AX,"*"&Name&"*")
Now I'm stuck on how I can return the dates & room info on a partial match (the name columns in the room sheet are "[First Name] [Last Name]" while the employee sheet is set up as "[Last Name],[First Name]") across an entire sheet. I've tried using regexmatch, filter, contains, and even the query function again, but I keep getting function errors.
I would super appreciate any formula help. :)

Formula to build report of employees that are not working between 2 dates

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

Calculate weighted usage of an item

I have a Google Sheets workbook with 2 worksheets.
Sheet 1 lists about 1000 items (components). The list could grow.
(ignore E through K columns in the above example)
Sheet 2 lists some products (200 or so at the moment, but the list could grow). Each product could contain up to 12 components. These are listed in columns C through N (all of these columns have data validation so that these need to be selected from Sheet 1's list of 1000 components). Column R contains the number of units of the product.
On sheet 1, next to each component, I want to calculate the number of units of the component used across all products. Of course countif will count only the instances of the particular component in Sheet 1!C2:N200. Similarly sumproduct doesn't fit the bill because 1. C through N are not numerical and 2. C through N are not fixed.
Is there a simple way to calculate the number of units for each component?
(without using VBScript/Javascript, and without copy-pasting the transpose list of components onto Sheet 2)
I am thinking some quirky way of using sumif or sumifs may be the answer here, but haven't figured out yet.
In Sheet1 cell B2. put this formula:
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A,QUERY(SPLIT(FLATTEN(Sheet2!C2:N&"|"&Sheet2!R2:R),"|",0,0),"select Col1,SUM(Col2) group by Col1"),2,0)))
if you want to return 0s instead of blanks for unused components, this slight modification should do it.
=ARRAYFORMULA(IF(A2:A="",,IFERROR(VLOOKUP(A2:A,QUERY(SPLIT(FLATTEN(Sheet2!C2:N&"|"&Sheet2!R2:R),"|",0,0),"select Col1,SUM(Col2) group by Col1"),2,0),0)))
Demo Sheet
A complementary way is to build a data base
=ARRAYFORMULA(SPLIT(FLATTEN(Sheet2!A2:A&"|"&Sheet2!C2:N&"|"&Sheet2!R2:R),"|",,false))
and then compute via a pivot table, added in
https://docs.google.com/spreadsheets/d/1Lokoms22tuqU53TlhAcdqaldQe_H7Pq8Jah2kBBYo7c/edit#gid=1233865099

How do I create a multiple sheets that use a google sheet named TOTAL as the data source?

How do I create multiple sheets that use a Google sheet named TOTAL as the data source? Each sheet must contain the same three columns from TOTAL and other specific data, for instance, FLUX will have six columns, three from TOTAL and three custom columns added manually.
I used a query function to import the data from TOTAL to FLUX so that updating data in TOTAL will update it also in FLUX
The data in TOTAL are not fixed. It will change adding rows, which might change the order of the list. For instance, adding the row 13 in TOTAL will shift down the data in column A:C in FLUX, but not columns D:F
Is that a way to keep the reference out of the QUERY part?
Here an example: Click me
you would need to create ID system and then you would be able to match your query with rest of the static columns. in sheet SALES remove that query and put IDs in A column. then your query will be:
=QUERY(TOTAL!A1:D, "SELECT A, B, C, D WHERE C is not null", 1)
where column A contains IDs and then you create new sheet SHEET3 and paste this query in A1
and this formula in E1:
=ARRAYFORMULA(IFERROR(VLOOKUP(A1:A, SALES!A1:G, {4,5,6}, 0), ))
I have the same problem and I can't understand few steps from the answer.
Firstly, the A columns of both sheets (TOTAL and SALES) must have IDs?
Secondly, I can't really understand how the Sheets SALES should look like. Should it be like, Col A = IDs, ColB to C query from TOTAL and Col E to G static data?
In this case is it still correct creating a query in Sheet3 reading data from TOTAL?
Thank

Google Sheets - Trouble with Query and Array

I'm struggling with the following and help/guidance would be appreciated. The attached Google Sheet has 3 sheets;
Sheet1 has 2 data fields (month, store name).
Sheet2 has 4 data fields (month, store name, fruit, quantity)
A query on Sheet3 in cell A3 outputs a set of months and store names from Sheet1 which is then used to find quantities of a given fruit from Sheet2 (in this example, it's apples). The results are listed on Sheet3 in columns D and E. I used both Index(Match) and Filter to output the Apple quantities as i tried to figure out my ultimate goal - how to use a single formula, including the query itself, to get to the aggregate apple total in Row 9 (i.e. without needing to do all the index(match) or filter formulas). Said another way, what formula on Sheet3 in cell D9 would run the query against Sheet1, use the results to find the month, store name, fruit, and quantity matches on Sheet2, and total them for a single output cell on Sheet3 D9?
Thoughts?
You can use a combination of counta(query()) to do this.
For A1:A that contains a mixture of fruit (apples, bananas, grapes, star fruit), use:
=counta((query(A1:A, "select A where A like 'apple'")))
Check out this very simple example sheet

Resources