Yes another "Argument must be a range" question - google-sheets

After struggling with this formula for over an hour, I turn to SO.
=SUMIF(indirect($A$1&"!$Q$3:Q"),indirect($A$1&"!$E$3:E"),"="&J5)
I am getting a Argument must be a range error here
The approach is simple - sum up whatever corresponds with J5 value (CSIQ in this case) on sheet referenced in $A$1
What am i missing here please?

try (if you want to sum Q):
=SUM(FILTER(INDIRECT($A$1&"!Q3:Q"), INDIRECT($A$1&"!E3:E")=J5))
try (if you want to sum E):
=SUM(FILTER(INDIRECT($A$1&"!E3:E"), INDIRECT($A$1&"!Q3:Q")=J5))

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)

Sumifs #ref error in google sheet - unexplainable

I have this very strange error which makes no sense to me.
I am using below formula to sum up sales values based on 2 criteria (one being month and the other one category)
=sumifs(Sales!$S:$S,Sales!$H:$H,D3,Sales!$Q:$Q,$A$12)
This formula works absolutely fine if I set cell D3 to 52020 (i.e. sum up all sales for may) - however, if I change the value to 62020 I am getting a ref error (same if I enter the value directly into the formula rather than using a cell). I tried other values and it looks like that only 62020 produces an error.
There are sales with 62020. In any case, this makes absolutely no sense to me especially given the error seems to come due to a Criteria not a range/ref.
I wonder if this is a bug (but probably I am missing something). Any ideas?
could be that for some reason your sheets converts it to date
62020 = 10/19/2069
try:
=INDEX(SUMIFS(Sales!S:S, Sales!H:H*1, D3*1, Sales!Q:Q, A12))

Using arrayformula() like continue with nested if()

My goal is to fill down formula while data exist in an adjacent column.
Here is my original formula:
=index(lookups!$M$2:$M30,match($A3,lookups!$N$2:$N30,0))
This formula works in that results are returned as expected.
I then tried this in the hope of it copying down:
=index(lookups!$M$2:$M30,match($A3:A,lookups!$N$2:$N30,0))
This resulted in #N/A "Did not find value in match"
Then I read this post and looked at the second most voted answer and tried editing my formula to this:
=arrayFormula(index(lookups!$M$2:$M30,match($A3:A,lookups!$N$2:$N30,0)))
This time the formula copy down as I hoped, but with a #VALUE error "Function IF parameter 1 expects boolean values. But 'ADT- Alaska Travel Vendor Activities (Search)' is a text and cannot be coerced to a boolean."
How can I tell sheets to copy the index(Match()) all the way down while data exist in column A?
See if this formula delivers the desired output ?
=ARRAYFORMULA(iferror(vlookup(A3:A, {lookups!$B$2:$B, lookups!$A$2:$A}, 2, 0)))

Hide #DIV/0! errors and #N/A errors

I want to hide all #DIV/0! errors and #N/A errors for data that hasn't been inputted. (So just have an empty cell.) The current data I have:
Rather than using the IF formula, I suggest using the IFERROR formula. That way you won't need to worry about possible error conditions.
Case of #VALUE! error:
=IFERROR("a" + 1,"")
Case of #DIV/0! error:
=IFERROR(3/0,"")
The second parameter is optional, so you can even simplify the formulas to:
=IFERROR("a" + 1)
=IFERROR(3/0)
How about using an if() statement, testing to see if there is an entry in the symbol column: if yes then do calculation: if not then blank.
I don't use google spreadsheets, but something like:
=if(a1="","",calculation)
assumes column a has the symbol info.
Same goes for the divide by zero error but check that the number of shares is greater than 0:
=if(A20>0,calculation,"")
Set the defaut color as with (so your text/value will be invisible) and add a condition if value different of zero than set color as black. So you will see only cell with corect values

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