Using the current SUMIF "row" in criteria - excel

I am trying to do something like this:
=SUMIF(H2:H55,VLOOKUP(insert placeholder for current row,Interfaces_to_Devices,5,FALSE)=A4,J2:J55)
IE I am trying to use the current row that I am evaluating to do a VLOOKUP of a value that needs to be equal to something I specify.
Thank you.
In this screen shot I did not include the VLOOKUP()="A4". That is supposed to be in there.

ROW() will return the number of the current row.
But the first argument to VLOOKUP is a cell reference or value.
If you explain what value you are trying to use in the VLOOKUP, how it is related to the current cell, then it is probably possible to use INDEX and MATCH (perhaps OFFSET) to achieve what you need.

=SUMIF(H2:H55,VLOOKUP(ROW(),Interfaces_to_Devices,5,FALSE)=A4,J2:J55)
Or
=SUMIF(H2:H55,INDEX(Interfaces_to_Devices,5,ROW())=A4,J2:J55)
If you simply REFERENCE the first value in column 5 of Interfaces_to_Devices, then drag down your formula you will simply reference each value going down the column without the need for a lookup, index, or match.
Notice in the picture below how i replace your formula with the cell reference to the 5th column in the table and in my first Row i Reference the first value in the column then as i drag the formula down it automatically references the equivalent cells in each row down the column.

Related

Is there any Excel function that can copy column's (first row's) name if the value matches?

I can't figure out a function that would automatically copy the first row value if the value on another rows matches 1. I would need the red dates to be automated.
Any advice would be very appreciated, thank you!
Excel problem
You can do it with
=INDIRECT(ADDRESS(1; MATCH(1;E2:ZZ2)+4))
The inner MATCH searched for "1" in the given array (from E2 to ZZ2). The "+4" is there, because you are beginning to search in column E (=5) and MATCH returns the column within your array.
The ADDRESS takes the first row and the column found by MATCH.
The INDIRECT returns the value of the given ADDRESS.
If you copy this formula down the rows, the search array (E2:ZZ2) is automatically adjusted to search the corresponding row.
=INDEX($E$1:$O$1;1;MATCH(1;E2:O2;0))
Replace semicolon with comma if your Excel version needs it.
If you have, you can also use Xlookup, it's a bit easier.
=XLOOKUP(1;E2:O2;$E$1:$O$1;"not found")

How to see if multiple columns match different conditions and return text

I'd like to return a "u" if the cell to the left is in column I on my other tab AND if the cell underneath is in column F on the other tab. How would I go about this please?
So far I have in cell f7: =IFERROR(IF(VLOOKUP(F8,Table!I:I,1,0)<>"","u",0),"")
but I need to also look in Table!F:F to see if the date from the cell underneath is in it.
EXAMPLE
Here is my data in tab 1:
Here is what I'm looking to do in tab 2:
If I understand your question correctly this formula should provide what you are looking for.
=IFERROR(IF(AND(VLOOKUP(F8,Table!I:I,1,0)=F8,VLOOKUP(F9,Table!F:F,1,0)=F9),"u",0),"")
Using the AND() function requires both tests to be TRUE in order for the evaluations to be TRUE. An OR() allows both to be checked but returns TRUE if either is TRUE. So using the AND() checks both conditions and returns "u" in your IF statement only if both are TRUE.
I changed the logical criteria to equals just to be sure the values match.
Hi Becca,
It seems the part that I missed in the first attempt was the across. I think the vlookup is your easiest way to do this, but you may have to rearrange your columns. If you cut the column I:I on the table tab, and highlight column F:F right click and insert cut cells this will line the data up better for the vlookup. Now if you use the below formula you can compare across.
=IFERROR(IF(VLOOKUP(F8,Table!F:G,2,0)=F9,"u",0),"")
What this does is it finds the look up value and returns the value from the other column. Then it compares the returned value to the value in the cell underneath. If they match you get a "u" and if not, you get a "0". If the lookup is an error, you receive a blank.
Ok let's try this. A $ turns a relative reference into an absolute reference. The following looks up the name in column "A" and returns the date in column "B". It then compares that date to the value of row 10 of the current column. If it is drug across columns it will update to that column. If you wish to lock the column and unlock the row simply move the $ to before the "B" for the "B10" reference.
=IFERROR(IF(VLOOKUP($A2,Table!$A:$B,2,FALSE)=B$10,"U",0),"")
[![enter image description here][3]][3]
If you only care that the date is in the list below you could use an HLOOKUP.
=IFERROR(IF(VLOOKUP($A2,Table!$A:$B,2,FALSE)=HLOOKUP($B2,$10:$10,1,FALSE),"U",0),"")
Then you will have to use an index match however, this will not work on Excel 2019 or older. You will most likely need to use Excel 365. It will work best if you are always checking against the same reference (say B10), but you can drag it across.
=IFERROR(IF(INDEX(Table!$B:$B,MATCH($A2&B$10,Table!$A:$A&Table!$B:$B,0))=B$10,"u",0),"")

Find the value located in the bottom row in excel

Let's say I've got a table like this
What I want to do is get a formula that always gets the last value in column B and put it on cell D1, so in this case I want to get the value "21" but then if I keep adding values to this list I want to always get the value placed in the last row on that list. is there a way to do this?
Found a way to do this.
=LOOKUP(2,1/(B:B<>""),B:B)
Sure. Use COUNTA(B:B) to count all the non-empty cells in column B, use ADDRESS() to build the address of the last cell and use INDIRECT() to pull the value of the said address.
or you can use INDEX() to combine indirect and address

#REF error when using INDEX function

I cannot understand why everytime I use INDEX in excel to find a value given the two criteria, I get a #REF error.
INDEX(C2:L1048576,MATCH(O1,A2:A1048576,0),MATCH(O2,B2:B1048576,0))
There were no deleted cells, nor were they shifted at any point in time. They have the same number of rows too. The arrays to search into are correct.
Thanks. I would appreciate if anyone can give me some guidance. I am new to the INDEX formula.
The formula you're using doesn't find a value according to two criteria. The comments you were given explain what you're actually doing.
INDEX returns one cell value from a given range, according to a row and column index - the location within your range, starting with 1. (If your reference has only one row or column, one of them can be omitted).
MATCH finds a value in a range and returns its index.
So finding one value in a one-dimension range is easy using these two functions, using something like this (with a range of one column and multiple rows) =INDEX(range,MATCH(value,range,0),1).
To find two criteria you need to tweak this concept. One way is to use concatenation of strings, using the & operator, and for this you'll also need to use an array formula (entering it using Ctrl+Shift+Enter) like this formula:
=INDEX($C$2:$C$1048576,MATCH(O1&O2,$A$2:$A$1048576&$B$2:$B$1048576,0),1)
It's not clear what you are trying to return, so this formula will return the corresponding value in column C. You can use this concept to return each value from the rest of the columns D:L, one by one, or concatenate them.

Get value from the cell above

Is it possible in Google Spreadsheets to reach the value of the cell just above?
Meaning: In one cell A2 I want to display the value from the cell above, that is A1. Not because it is that coordinate, but because it is the cell above. I do this by simply setting the value equal to the above cell:
If I create a new row in between those two, I get this:
As we know, no change in the values, since the reference is not relative in this way. How can I make it relative to the cell, so I always pick the cell above nomatter what is changed? I want the result to be this:
The term relative is wrong in the case of course, but I hope you get my point. I both want the usual relative behavior (so I can move the cell itself and its reference will fit to the new coloumn and row) as well as the behavior that the reference does not point towards a specific fixed coordinate but rather a specific path from the cell itself.
You can address it using the following function:
=INDIRECT(ADDRESS(ROW()-1;COLUMN()))
COLUMN() returns a numeric reference to the current column
ROW() returns a numeric reference to the current row.
In the example here, subtracting 1 from the row gives you the previous row. This math can be applied to the ROW() and/or the COLUMN(), but in answering your question, this formula will reference the cell above.
Then we have ADDRESS() which accepts a numeric row and column reference and returns a cell reference as a string.
Finally INDIRECT() allows you to pass a cell reference in as a string, and it processes it as a formula.
Google Spreadsheets give you help hints as you type, so you should get a full explanation of each function as you type the formula above in.
For anyone who stumbles across this question, you can also specify the column by doing something like this:
=INDIRECT("A" & ROW()-1)
This comes in handy if you are returning values in Column B but checking against the previous row in Column A.
The shortest, and easier for VisiCal old timer is the old RC syntax with relative values…
=INDIRECT("R[-1]C[0]"; FALSE)
Very visual, simple code template to remember and modify, and very short.
Regards, Antoine

Resources