How to make Vlookup index column dynamic? - arrays

How could I make VLOOKUP() work somewhat like this?
=VLOOKUP(Z10,Sheet1!A5:Z100,COLUMN(MATCH("ID",Sheet1!A5:5,0)),0)
...where the col index is obtained by matching the column header's with what's entered there.
Thank you!

should be:
=VLOOKUP(Z10, Sheet1!A5:Z100, MATCH("ID", Sheet1!A5:5, 0), 0)
where
=MATCH("ID", Sheet1!A5:5, 0)
match will output the number of column. lets say ID header is in E5. that's 5th column of range A5:5 so the output will be 5, therefore, vlookup will output the 5th column from A5:Z100 which is E column. summary: look for Z10 in A5:Z100 and if Z10 is found in A5:A100 range, output the matching column with header ID

Related

google sheet : How to vlookup by matching value in between max and min?

I have 2 sheets like this :
In that 2nd sheet, i want to lookup the id (S/M/L/XL) by checking if value is in between the Min value and Max value. So the goal is to have something like that 2nd sheet where in 'level' column, i need to put a formula so it will check the value is between what range so then it will retrieve the correct 'id' from 1st sheet.
the rule is if the value is >= minvalue and < max value
How can i do this ?
Thanks
use:
=INDEX(IF(A9:A="",,VLOOKUP(A9:A, {C2:C5, A2:A5}, 2, 1)))
Your first table, has overlapping values, so I suggest you think better about the rules you want to apply.
For example, 1, according your table can match both "S" and "M" , same for 3, which can be "M" or "L".
Once you have resolved that, you can use the QUERY function.
Example:
=QUERY($A$2:$D$5,
"select A,D where C<="&A2&" AND D >="&A2&" ORDER BY D DESC LIMIT 1 ")
Working solution can be found here:
https://docs.google.com/spreadsheets/d/1oLVwQqihT_df2y_ZQnfx7By77HnKSFz0bcbOzMuWqOM/edit?usp=sharing
Rather than have min and max columns, you could just use one column to list incremental values that determine the next size, and use vlookup() with a sort option of true - this avoids overlapping values:
=arrayformula({"level";if(A2:A<>"",VLOOKUP(A2:A,{Source!C:C,Source!A:A},2,1),)})

Inserting rows to dataframe on multiple indices based on conditions in python-pandas

I have a dataframe like this
Whenever I see an instance where start is followed by stop and DURATION column is 0, I need to insert a row after that (at 4th and 8th row in this case), which should contain pretty much the same values of its previous row, but the event column should be denoted by E1.
I need to get something like this
How can I achieve this since multiple indices can have the values with START-STOP and duration as 0?
Thanks in advance!
If you always have a sequence 'start-stop' (stop is always followed by start), it will work:
df.loc[(df['DURATION'] == 0) & (df['event'] == 'stop'), 'event'] = 'E1'
What means: Put 'E1' in column 'event' for each row which has 0 in column 'DURATION' and 'stop' in column 'event'.

Finding adjacent column values from the last non-null row of a certain column

Is there a simple in-built function to select adjacent values from the last non-null row for a certain column?
In the below example the last non-null value in Column A is "E", and I'd like to select the corresponding value "13" from the next column.
Try:
=VLOOKUP(INDEX(A:A,MAX((A:A<>"")*(ROW(A:A)))),A1:B,2,0)
Refer Selecting the last value of a column. There are 22 answers toi choose from.
I like =INDEX(I:I;MAX((I:I<>"")*(ROW(I:I)))). It is one of the shortest and it copes with blank rows.
Add VLOOKUP and you can get the value on the adjacent columns.
try:
=QUERY(A3:B, "select B where A !='' offset "&COUNTA(A3:A)-1)
or:
=ARRAYFORMULA(VLOOKUP(INDIRECT("A"&MAX(IF(A2:A="",,ROW(A2:A)))), A2:B, 2, 0))
or:
=ARRAYFORMULA(VLOOKUP(INDEX(QUERY({A2:A, ROW(A2:A)},
"where Col1 !='' order by Col2 desc"), 1, 1), A2:B, 2, 0))
=indirect("B" & max(ARRAYFORMULA(row(A1:A)*if(A1:A="",0,1))),true)
or
=indirect("B" & arrayformula(max(if(A1:A<>"",row(A1:A),0))),true)
or with offset
=offset(B1,ARRAYFORMULA(MAX(if(A:A="",0,row(A:A))))-1,0)

Array formula to check for blanks

I have a google sheet with customer orders.
Column A contains the order number
The next four columns contain various data, filled at various stages of the order. (Columns B through E)
In Column F I'd like to have an array formula that checks when the orders are complete, i.e. each column in a row is filled in, for all rows that contain an order number.
Therefore, if A2:E2 are all filled with data, then in F2 it should state "Complete".
I've tried:
COUNTA
ISBLANK
AND
OR
COUNTBLANK
All formula work on a row by row basis, but not when entered in an arrayformula.
=ArrayFormula(if(and(LEN(A2:A),COUNTA($B2:E)=0)="True","Complete","There be blanks afoot")
Or
=ArrayFormula(If(LEN(A3:A),IF(COUNTBLANK($B2:$E)>0,"Blanks","No Blanks"),""))
Test sheet can be found here:
https://docs.google.com/spreadsheets/d/1mNIGRh910k_q9J2P6mzv9q-h-me3zxbCWeJ2mcaFsXQ/edit?usp=sharing
try:
={"Status"; ARRAYFORMULA(IF(A2:A<>"", IF(MMULT(
IF(B2:E<>"", 1, 0), {1;1;1;1})=4, "Complete", "Still blanks"), ))}

How to use vlookup formula to look at two values before displaying a value

I want my vlookup formula to first look for a date (column A), then look for a person's name (column B), then display the value of column C. I can get the formula to display the person's name (column B) but not sure where to go from here...
=VLOOKUP(L5, {DATA!A:A, DATA!B:B}, 2, 0)
try like this:
=ARRAYFORMULA(VLOOKUP(E2&F2, {A:A&B:B, C:C}, 2, 0))
=ARRAYFORMULA(IFERROR(VLOOKUP(E2:E&F2:F, {A:A&B:B, C:C}, 2, 0)))

Resources