How to count multiple ranges that have a status next to them? - google-sheets

I am attempting to count multiple matching ranges that also contain "Done" next to them.
Currently, I am able to use this query to count the Totals, but can't figure out how to make sure it only counts the ones that are "Done"
=SUMPRODUCT(COUNTIF('Subject'!A:A,'Jobs'!A:A))
This is the desired result:
Results Sheet

You should use VLOOKUP with ARRAYFORMULA to fetch the statuses of the column and COUNTIF to match only the "Done" status.
For First:
=COUNTIF(ARRAYFORMULA(VLOOKUP(Subject!A:A, Jobs!A:B, 2, FALSE)), "Done")
For Second:
=COUNTIF(ARRAYFORMULA(VLOOKUP(Subject!B:B, Jobs!A:B, 2, FALSE)), "Done")

Related

Combine / merge contents of columns in Google Sheet into a single column based on a condition

I have a spreadsheet with multiple columns. Each column represents a recipe. Each column has a week number (e.g. 2, 3, 4)... Below the week number, we have a variable number of ingredients. I want to be able to merge all the ingredients from a given week into a single column.
Sample Data
I know how to statically merge ranges e.g. {B4:B20;C4:C20} and I can also think of using an if statement to check the week value e.g. =if(B1=2,{B4:B20;C4:C20}) but that's not close to what I want. I need to check the range B1:Z1 for the value of the week and if that value is X (let's say 2) then take the ingredients in B2:B and tack them on to C2:C and so on...
If I'm understanding you correctly, this should do it:
=QUERY(FLATTEN(FILTER(B3:Z,B1:Z1=2)),"WHERE Col1 Is Not Null")
FILTER keeps (i.e., "filters in") only the data in B3:Z where the header is 2.
FLATTEN forms one column (blank cells and all) from the FILTER results.
QUERY keeps only non-blank (i.e., Is Not Null) entries from that single-column list.

Incrementing a column in a group using an Array Formula in Google Sheets

I am having difficulties trying to get an array formula to increment a column and restart the increment whenever a condition has been met.
Here is an example of what I am trying to achieve, but this has been done manually. It would be great if this could work in an array formula as we'll be adding more rows and would rather not drag the formula down.
[Update based on feedback of the original post]
Column A contains a list of names and teams.
Names are already organised into teams.
The aim is to go through each row and provide a name with an index starting from 1.
Then when a new team is found in column A the index starts again from 0.
The aim is to make this an Array Formula to avoid having to manually re-add the formula when more rows are added.
Link to sheet:
https://docs.google.com/spreadsheets/d/1K00LRFNrN99fFXQO1tzp8jjZeCuTxwENXNGuLj0K0ao/edit?usp=sharing
Example
Any thoughts or advice on this would be greatly appreciated.
I've added a new sheet ("Erik Help") to your sample spreadsheet. It contains the following formula in B1:
=ArrayFormula({"ID Index"; IF(A2:A="",, IF( REGEXMATCH(LOWER(A2:A),"team"), 0, ROW(A2:A) - VLOOKUP(ROW(A2:A), FILTER(ROW(A2:A), REGEXMATCH(LOWER(A2:A),"team")), 1, TRUE)))})
The header text is included in the formula. You can change it as you like.
If a cell in A2:A is blank, the corresponding cell in B2:B will be as well.
If REGEXMATCH finds a match with "team" in the lowercase rendering of a cell in A2:A, 0 will be returned for the corresponding cell in B2:B.
Otherwise, VLOOKUP will lookup each remaining row number in a FILTERed array containing only those row numbers where the word "team" appears. (In your sample set, that will be 2, 8, 12). When the exact match is not found (which it will not be for any remaining row), TRUE tells VLOOKUP that, since the search array is in strict ascending order, we want it to "bump back" to the most recent value found. In each case, the returned row number of the most recent row containg "team" is then subtracted from the actual row number to produce the recurring incremental numbering 1, 2, 3, etc.
try:
=INDEX(IFNA(1*IF(REGEXMATCH(A2:A, "Day"), 0, REGEXEXTRACT(A2:A, "(\d+)"))))

How do I add up the value of column B if column A meets a certain condition for each value in column A with one formula?

Below is an example of the values I'm trying to add. My goal is not to use the filter formula for every line again. This is because it takes a lot of resources from the processing power that google sheets uses.
The words in the left list below occur several times in combination with a certain number. I want to have a unique list as shown on the right where the values from the left row add up when the words are equal (without using a filter formula for each line).
This formula
=arrayformula(vlookup(A:A, A:B, 2, FALSE)))
comes very close, but returns only one value even though there are multiple matches. I want all values that matches returned.
try:
=QUERY(A:B, "select A,sum(B) where A is not null group by A label sum(B)'summed'", 1)

Match two columns on different sheets and post back some columns to third sheet using formula

Column A of Elements sheet has Ids. Column B of Connections sheet has Ids
I need to match on these two columns and post back columns 2, 4, 6 of the Elements sheet to a third sheet
I am trying this formula but I am unable to get it to work, there is no error but nothing is returned
=ArrayFormula(iferror(vlookup(Elements!A1:A893, Connections!B1:B893, {2,4,6}, 0)))
Thanks
The IFERROR will be stopping any error messages being shown. One of these alternative methods might work:
=query(Elements!A:F, "select B,D,F where A matches '"&TEXTJOIN("|",1,Connections!B1:B893)&"'")
=filter({Elements!B:B,Elements!D:D,Elements!F:F},match(Elements!A:A,Connections!B1:B893,0))

Use vlookup to get exact match while is_sorted is TRUE

Is it possible to use Google Sheets VLOOKUP to get an exact match while using the sorted==TRUE option ?
Prefer to use VLOOKUP because I'm return multiple columns.
Would like to use the sort option because the data range is very large
(20,000 rows)
I didn't find any option in while reading the docs. Asking in case, there is an option I may have missed.
EDIT; I also checked the MATCH function, but the sort option is identical to VLOOKUP - so same situation.
EDIT; an ArrayFormula spreadsheet for users to reference
EDIT; full formula for my purposes for reference using Answer (double VLOOKUP) - very fast for even 20,000 rows
ARRAYFORMULA(IF(VLOOKUP(B:B,SORT(UNIQUE(B:B)),1,TRUE)=B:B,VLOOKUP(B:B,QUERY(A:B,"select B, count(A) group by B order by B label count(A) ''"),2,TRUE),0))
The double vlookup approach is to search for the primary key itself first, and only if it's found, proceed to retrieving the values from other columns.
If A:B is already sorted by A, and the value we look for is 42, then the formula is:
=if(vlookup(42, A:B, 1, true) = 42, vlookup(42, A:B, 2, true), na())
where the first vlookup checks if 42 is in column A, and only then passes the job to the second.
If A:B is not sorted, it can be sorted on the fly as in
=if(vlookup(42, sort(A:B), 1, true) = 42, vlookup(42, sort(A:B), 2, true), na())

Resources