Index Minif excel - excel-formula

I need a formula that looks for a value in column A, finds the smallest value of that row and displays the corresponding value of a row on the top of the sheet (row 3 in my case) where the smallest value has been found.
also would like to find the second and third smallest value and display the value of row 3.
For example: I need to lookup X in the first column, find the smallest value in that row (1) and display the value on the row on top of that column (D)
and second smallest value for X to display C, third smallest for X to display E.
enter code here
A B C D E F
Z 6 8 9 5 2
X 7 2 1 3 7
Y 9 2 6 1 6

This codes should work:
=INDEX($B$2:$F$2,MATCH(MIN(IF($B$1=$A$3:$A$5,$B$3:$F$5)),INDEX($B$3:$F$5,MATCH($B$1,$A$3:$A$5,0),),0))
!https://imgur.com/2YFu39E

Suppose your data are in range A1:F4 as shown below:
You can use the following formula to find the 1st, 2nd and 3rd smallest value in the row starting "X". Put it in Cell I2 and drag it down.
=SMALL(INDEX($B$2:$F$4,MATCH("X",$A$2:$A$4,0),),H2)
Then you can use the following formula to find the corresponding value in the row starting "Z":
=INDEX(INDEX($B$2:$F$4,MATCH("X",$A$2:$A$4,0)-1,),,MATCH(I2,INDEX($B$2:$F$4,MATCH("X",$A$2:$A$4,0),),0))
It is basic INDEX+MATCH approach. If you have problem understanding the solution, I suggest you to google some online tutorials on the use of INDEX+MATCH. SMALL function is used to find the nth smallest value as requested.
Cheers :)

Related

extract ranges from column values

I've column of values 1-10 missing 4 and 7 can I extract 1-3,5-6,7-10.
Currently I'm using this formula =IF(A3=A2+1,C2,C2+1) which gives me helper column sort of help
but my list is long If I could extract ranges that would be helpful.
There are no duplicates
I'm not sure if I understand exactly what you mean, but this is what I have done until now: I have copied the same columns A and B, and I have added following columns:
Column C : =COUNTIF(B$2:B$16,B2)
Column D : =IF(AND(C2=C3,C3<>C4),"End",IF(AND(C2<>C3,C3=C4),"Begin"))
The result looks as follows:
As you can see:
The number 1 from column B ends at row 6, and D6 indeed indicates "End".
The number 2 from B starts at row 7 (D7="Begin") and ends at row 8 (D8="End").
The numbers 3 and 4 are not correctly handled but:
As far as 5 is concerned: it starts at row 11 (D11="Begin") and ends at row 15 (D15="End").
There still is some finetuning to do but I guess you see how the ranges start being unfold.

EXCEL: Take the average of a column in row (n-5,n-1) if row n fulfills a condition

There are 50 rows. The first column (A), each row has has a ID number. They are not sorted in any way and should not be either and there are no duplicated ID numbers. When the ID is 0 then consider 4 rows before that row, take the mean value of those values in clumn C between those 4 rows. If it helps It is always the last row that has value ID = 0.
What I have done so far is that I can find the ROW number of the ID = 0 using the following formula:
ROW(INDEX(A3:A53,MATCH(TRUE,INDEX(A3:A53=0,),0)))
Now I don't know how to navigate 4 rows upwards and take the corrosponding values in Column C.
If you use an extra column (say column Z), then paste this code into that column starting on row 4 (NB it won't work properly for the first 3 rows because there are not 4 above to check).
=IF($A4 =0, AVERAGE($C1:$C4), "Not Relevant")
so put that code in Z4, then press ctrl+E to flash fill it downwards.
Hopefully, on each line where the ID is 0, there will be an average of that line and the previous 3 in column Z on that row.
Use:
=AVERAGE(INDEX(A3:A53,MATCH(TRUE,INDEX(A3:A53=0,),0)-5):INDEX(A3:A53,MATCH(TRUE,INDEX(A3:A53=0,),0)-1))

Excel formula to Sum a row up to specific column number

I want to sum a row like
A B C D E
2 4 3 5 5
I want the formula to sum from A1 to some column number like It can be up to column 4 (D1) or up to column 5 (E1). I can retrieve column number but how to add up to that column number is what I am asking for.
Start of sum is fixed A1 but end is dynamic (not fixed)
Any solution will be highly appreciated
Say we want to sum up part of the first row.
Place the first column number in A2 and the last column number in A3. Then:
=SUM(INDEX(1:1,A2):INDEX(1:1,A3))
In your posted example, you would put 1 in A2.
It's probably easiest to sum up the entire row =SUM(2:2) (to sum the values in row 2) or if you have some other data at the beginning (or you want the sum to show up at the beginning) you can do something like =SUM(B2:XFD2)
I got that last column name here: https://www.quora.com/What-is-the-last-column-name-in-an-Excel-file
and checked it was the same as newer versions here: https://support.office.com/en-us/article/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3#ID0EBABAAA=Newer_versions

How do I make a cell value represent a number in Excel?

I have
Year 1 2 3 4 5 6
I'm trying to make it so that each year number 1-6 is equal to another number value i.e. Year 1 is equal to 5. Year 2 is equal to 6.
You will not be able to store one value in a cell and use a different value for calculation. However you may do this calculation with the help of a lookup from another table,
Assuming you have the years in Column A and the corresponding mappings are in Column E and F, you can use the below formula in Column B,
=INDEX(E:F,MATCH(A1,E:E,0),2) * 2
This formula lookups the value in A1 in the table E:F and returns the corresponding Column F element. That is finally multiplied with the 2 to show your result. Instead of just using just A1 for multiplying by 2, you should be using INDEX(E:F,MATCH(A1,E:E,0),2). Hope this helps.

Give column number of first column with symbol

So say I have a sheet like the following:
Row 1 2 3 4 5 6
1 x
2 x
3 x x
4 x
5 x x
6 x
And I have another sheet which I want to encapsulate the data with:
1st appeared
1
2
1
4
2
6
I'm basically trying to construct the second sheet. Is there a way for each row to start at column two and go up to the ith column and display where the first 'x' appears. (Note that we can assume that every row will have at least 1 'x' when the row and column meet forming a diagonal down the entire first sheet) [Note that my first spreadsheet is roughly 5,000 x 5,000 hence why I'd like a nice formula for this instead of doing things by hand =)]
Thanks in advance!
The MATCH function return the relative position in either a row or column. Use this formula in your second worksheet.
=iferror(match("x", sheet1!1:1, 0) - 1, 0)
Fill down to retrieve the correct column index or zero if not found. A 1 is subtracted since hte want the position relative to column B. The IFERROR function return a default 0 is no match is found. Substitute "" in place of the zero if you want nothing displayed.

Resources