Google Sheets SUMIFS different criteria with checkbox - google-sheets

i've the following formula the problem i've is, this isn't working as it should be.
=SUMIFS(E9:14,$I$16:$I,FALSE(),$H$16:$H,G8)
E9:E14 is the part which should be summed up when the checkbox in I16:I = FALSE and if the name matches in H16:H from G8. My problem is I am getting this error
The array arguments of "SUMIFS" vary in size
My question would be, how do I get this exact formula to work? Exactly these areas have to be covered and cannot be changed, otherwise everything else is broken.
EDIT: Added example spreadsheet
https://docs.google.com/spreadsheets/d/1DdTSZAfGTpoeun3k2qqkDMG1jnaUaSz6wgSf2heIIDI/edit?usp=sharing

You need to adjust your ranges. Here's how =SUMIFS() works and then you'll see why you need to adjust the function.
=SUMIFS() looks for ranges and then applies the logic. So when you are telling the function to summarise E9:E14 it interprets it as:
SUM(E9,E10,E11,E12,E13,E14)
provided the following conditions. The conditions will tell the function whether to include each of the components (i.e. E9,...,E14).
Whether a condition is met or not is decided using a simple boolean (true/false) array. This could for example be I9:I14=FALSE which is interpreted as the array
{IF(I9=FALSE),IF(I10=FALSE),...,IF(I14=FALSE)}
resulting in an array similar to this:
{TRUE,TRUE,FALSE,FALSE,FALSE,TRUE}
(assuming the conditions I9, I10 and I14 are met but not the other three. The same is done for the second condition (the values in column H being equal to the value in G8, resulting in another array similar to this:
{TRUE,FALSE,FALSE,TRUE,FALSE,TRUE}
(assuming that only the values in H9, H12 and H14 are equal to G8.
When the function compares the two condition arrays and returns an aggregate array similar to this:
{TRUE,FALSE,FALSE,FALSE,FALSE,TRUE}
because only for the first and the last value the conditions are met. Therefore the =SUM function becomes like this:
SUM(E9,FALSE,FALSE,FALSE,FALSE,E14)
where FALSE = 0 so it returns
=SUM(E9,E14)
Here's where you get into trouble
You try to pass the function conditional arrays that are of a different size to the sum array (E9:E14), in effect asking it to compare apples and the age of your neighbour. What you need to do is to create the calculation you have in column E in a new column in rows 24 down and use that as the sum range in =SUMIFS().

Related

How can I find the name of the person ranked 1?

What I'm trying to do is find the name of the person who is ranked number 1 in the table shown below. I have tried =LOOKUP and =VLOOKUP but I get an error saying that a result can't be found, even though it's obviously there. I assume that I'm either using the wrong function or just not using it right.
I tried =VLOOKUP(1;D2:H19;1) and =LOOKUP(1;D2:H19;1) but neither seems to work.
Answer
The following formula should produce the behaviour you desire:
=INDEX(D2:D,MATCH(1,H2:H,0))
Explanation
=VLOOKUP can only be used to find values to the right of a search key. To find values to the left of a search key, use a combination of =INDEX and =MATCH.
The =MATCH function searches a specified range for a specified value and returns the relative position of the value in that range. In this case, the value to search for is 1, the range to search through is H2:H, and the 0 at the end specifies that the range is not sorted in any way.
The =INDEX function returns the contents of a cell within a range having a specified row and column offset. In this case, the range is D2:D, and the row is whichever row is returned by =MATCH. =INDEX could take a third argument if it was desired to specify a row offset as well, but that is not necessary here.
Functions used:
=INDEX
=MATCH
You sort your ascending order based on rank then return your desired data using INDEX() function. Try-
=INDEX(SORT(D2:H500,5,1),1,1)
=vlookup(1,{H2:H19, D2:D19},2)
Since vlookup only searches the 1st column of the input range, to use it, you need to flip the columns by composing a local array: {H2:H19, D2:D19}.
{} means concatenation. , in it means horizontal concatenation. With that, the rank column is now the 1st column in the input of vlookup and now vlookup works.
With our local array, the 2nd column are the names and therefore index should be 2.
Also note the use of comma to separate function inputs.
your VLOOKUP formula should look like:
=VLOOKUP(1, {H2:H19, D2:D19}, 2, 0)
also try just:
=FILTER(D:D; H:H=1)
or:
=SORTN(D:D; 1; 1; H:H; 1)
You can use query (usefull in case of ex aequo)
=query(D2:H,"select D where H=1",0)

How to get rid of the array size error in this scenario while using Countifs()

I have two columns and am trying to count the nonblank cells in column B based on a specific corresponding value in column A. So I am using COUNTIFS($A$3:$A,"GA",len(trim($B7:$B)),">0") to calculate that.
First criteria range is Column A and the criteria is if cell value equals "GA".
I want the second criteria range to be Column B and the criteria to be len(trim(cell)) > 0 but obviously I am not specifying it correctly and getting the following error, instead of the expected result of 7.
Please help in how I should achieve this.
Typo? Should be...
=COUNTIFS($A$3:$A,"GA",len(trim($B3:$B)),">0")
(You had $B7:$B.)
You can shorten this anyway:
=COUNTIFS(A3:A,"GA",B3:B,"<>")

Pick the greatest number in a range that is also less than the corresponding number in another range's row

I have two sets of data in columns A and B. I would like to pick the maximum value from column A which is also less than the value in the corresponding row in column B. I think I ought to be able to do this with the MAXIFS function but all the examples I can find compare against static values. I tried these options
=MAXIFS(A1:A10, B1:B10, "<")
=MAXIFS(A1:A10, B1:B10, A&"<"&B)
but neither of them worked as expected. In the first case, it is always 0 suggesting the condition is never met, in the second it gives an error.
I know that I could do this by creating a separate region of cells which first filter out the data that doesn't match the conditional and then simply pick the max from what remains but I'd rather do it in a single cell if possible.
Is there a syntax for this comparison and, if so, what is it?
To the best of my knowledge there isn't a way of getting it to work with MAXIFS.
You can write this
=maxifs(A:A,A:A,"<"&B:B)
and it will accept it, but it just uses the first value in column B and doesn't do a side-by-side comparison.
So you have to do it another way e.g. with a combination of Max and If:
=ArrayFormula(max(if(A:A<B:B,A:A)))
or you can use max with a filter or query:
=max(filter(A:A,A:A<B:B))
=max(query(A:B,"select A where A<B"))
=ARRAY_CONSTRAIN(ARRAYFORMULA(
IF(LEN(INDIRECT(ADDRESS(ROW(), COLUMN(B:B))))>0,
IF(INDIRECT(ADDRESS(ROW(), COLUMN(B:B)))<MAX($A$1:$A),
MAX($A$1:$A), LARGE(UNIQUE($A$1:$A), 2)), )), 1, 1)

ArrayFormula, Google Spreadsheet

This seems to be a simple problem that I cannot get around. I have the following formula (works fine).
=MEDIAN(FILTER('Filtered-Data'!$D$4:$D,'Filtered-Data'!$C$4:$C=B3))
What I want is to use ArrayFormula to get a column wise result for the range B3:B instead of just B3
Can this be done?
First idea was to use Google QUERY function, however it does not support standard SQL SELECT ... WHERE... IN (valA,valB...) clause. However thing you want is achievable with ARRAYFORMULA. The trick is to match appropriately two columns, handle errors, and apply appropriate filtering (multiline for readability):
=MEDIAN(FILTER(Filtered-Data'!$D$4:$D,
ARRAYFORMULA(IF(IFERROR(MATCH
(Filtered-Data'!$D$4:$D,'Filtered-Data'!$C$4:$C=B3:B,0),0)>0,TRUE,FALSE))))
Explanation:
ARRAYFORMULA(MATCH(col1,col2,0)) finds in array first row containing value matching criteria, 0/1 determines whether matching starts from top or bottom. For standalone use, MATCH stops after producing first result. Applying ARRAYFORMULA on MATCH gets us close to what we want - it produces an array of results. However, if item is not matched, error is returned, so you get something like below, in a column:
N/A
2
3
1
3
2
N/A
N/A
N/A
1
3
These N/A stuff will do us no good, since we always want some kind of row number. Here comes IFERROR, which replaces all N\A with good ol' "0": IFERROR(MATCH(col1,col2,0),0)
Google Spreadsheet never counts rows from "0" (it starts from "1", only offsets are zero-based), so this is pretty safe unless your data contains "0" - than change it to anything else safe for your case.
Since FILTER expects in filtering_criteria single column array of booleans or expression that evaluates to array of booleans (https://support.google.com/drive/table/25273?hl=en ) we need to make sure ARRAYFORMULA produces such array of booleans. IF comes in handy - always produces either TRUE or FALSE: IF(IFERROR(MATCH(col1,col2,0)>0,TRUE,FALSE)
Now re-apply ARRAYFORMULA on that stuff, to work on array & render an array result instead of single result: ARRAYFORMULA(IF(IFERROR(MATCH(col1,col2,0)>0,TRUE,FALSE)) and put it inside FILTER... voila, it works.
For reference see: http://productforums.google.com/forum/#!topic/docs/PpnZinkLzQs

Getting Corresponding Cell In Google Sheets?

I have a Google sheet for tracking my weight. I have two columns: Date and Weight. While the goal is to have the weight column sorted in descending order, that doesn't always happen in reality...
The data essentially looks like this (weights changed to far lower values, of course):
Date |Weight
04/01/10|195
04/02/10|194
04/03/10|190
04/04/10|198
etc.
Anyway, I have a cell in another spot on the sheet that shows the minimum value from the weight column using this formula
=(Min(B:B))
What I would like to do is display the corresponding date cell for whatever the minimum value from the weight column is. So, with this dataset, I want to show 190 for weight and 04/03/10 for date. Is there any way to get that corresponding cell? I looked through the function reference for Google docs, but can't get anything going. I tried using some of the functions from the Lookup category, but got nowhere. Most want a cell reference, but the min() function returns a value. I think I need to somehow get min() to give me a cell reference, but I don't know how to do that. HLOOKUP() sort of seemed like it might be appropriate, but the docs were a bit spotty, and it didn't do anything but error out the cell.
Of course, I may be barking up the wrong tree entirely.
Thoughts?
I would use the following two formula's:
MIN(B2:B)
FILTER(A2:A;B2:B=minimal value)
If there are more results, they need to be included as well.
See example file I've created: Getting Corresponding Cell In Google Docs Spreadsheet?
Not barking up the wrong tree, actually very close:
=index(A:A,match(min(B:B),B:B,0))
should meet your requirement.
Working inside out: min(B:B) (as you had) returns the lowest weight (ie 190) in ColumnB.
match then finds the position of that value relative to the start of the range in which the value is searched for. So assuming Date is in A1, that returns 4, being the fourth row in ColumnB, where 190 is. The 0 in the formula is to ensure that only the position of an exact match is returned.
Now we know we need the content of the fourth row we can go looking for the value there in ColumnA with index, returning 04/03/2010.
Not all is ideal however. It is possible that a weight of 190 was achieved on separate days. It is the nature of match that where an exact match is required and found the function stops looking for any further instances. Hence as things stand 04/03/2010 will be returned for 190 however often that is the weight for a day after 04/04/2010 - unless other steps are taken, such as to delete/remove/ignore data from 04/03/2010.
You need to change the order of the column as the search column (the weight should be the first in the search array. Then you can use the VLOOKUP formula:
=VLOOKUP(C7,A:B,2,false)
C7 holds the MIN formula that you used: =(Min(A:A)) - note the column order change
one-cell solution to get minimal value with the latest day:
={MIN(B:B), TO_DATE(VLOOKUP(MIN(B:B), SORT({B:B,A:A}, 2, 0), 2, 0))}
to get all minimal values with dates:
=QUERY(A:B, "select B,A where B matches '"&MIN(B:B)&"' order by A desc", 0)

Resources