Excel: How to find highest value in range based on adjacent cells with the same value - excel-formula

I have a column A with names (with duplicates), column B with language codes, and column C with numeral values.
I am struggling to make a formula that would find the highest value in column C, but only for those rows that have the same name – and return the value of column B for the row with that highest value for each unique name in column A. The output should be in another columns, like this:

I think this is what you're looking for:
=INDEX($B:$B,MAX(IF(($C:$C=MAXIFS($C:$C,$A:$A,$E2))*($A:$A=$E2),ROW($C:$C),"")))
Enter the formula in cell F2 with ctrl + shift + enter since it's an array-formula.
I search for the maximum value in column C if the value in column A equals the value in the cell in column E on the same row.
Then I check whether each value in column C equals that maximum value and check whether the value in column A equals the value in column E. If both are true return the row numbers of these en search for the maximum value of these row numbers.
The outcome is the row number of the maximum value that equals the name you searched for.
Using index results in the position of that row number in the desired column (B).
If you're using office 365 you can type =UNIQUE(A:A) in cell E2 to get the unique names listed (prior to adding the formula mentioned above in F2

Related

I am checking to see if any values in column C match with values from column B

I need preferably a formula or macro in excel 2013 to do the following:
Check if any given values in column C match with values from column B.
If they do I want to take the corresponding value from the same row in column A as the matched items in column B.
I then want to take those values from column A and put them in the same rows in column D.
Specifically, I am checking to see if any ID's in column C match with ID's from column B. If they do I want to take the corresponding city ID from column A in the same row as the matched items in column B.
I then want to take those values from column A and put them in the same rows in column D.
I used this formula =VLOOKUP(C6; A2:B14; 1; FALSE) but it returns #N/A
VLOOKUP will always use the first column as lookup_array. But in your case, you are using the second column for lookup_array, and wanting to return the value in the first column. So VLOOKUP is not appropriate.
Depending on your version of Excel, you could use INDEX(MATCH or XLOOKUP:
=INDEX($A$2:$A$14,MATCH(C2,$B$2:$B$14,0))
=XLOOKUP(C2,$B$2:$B$14,$A$2:$A$14)

Making a cell in column B display the largest value in column A

I have 2 columns, H&I with numbers. The values in H correspond to different ID numbers, and I has measurements.
I am trying to figure out a formula that would post in cell K3 the highest value in column I. I also want cell L3 to say the corresponding value in column H (relative to the new highest value/new value of cell K3).
I tried to figure out an if statement that works, but I couldn't get it just right.
No need for an IF, you can use an INDEX/MATCH:
=INDEX(H:H,MATCH(MAX(I:I),I:I,0))
MAX(I:I) will get the maximum value in column I
MATCH will get the row it is in
INDEX will then return the content of the corresponding cell in column H
To have both the ID and the max value, use:
=INDEX(H:H,MATCH(MAX(I:I),I:I,0)) & " " & MAX(I:I)

Lookup one cell in another sheet then return corresponding value

I have two sheets containing various columns in which two columns contains document number and prices. Now I want to match cell K3 (a document number ) of Sheet 1 within column D (all document numbers) of Sheet 2. If match exists, then i want the corresponding price mentioned in Column V to be returned.
This is the formula I've tried:
=VLOOKUP(K3,'Sheet1 (2)'!D2:D896,22,FALSE)
The VLOOKUP documentation is helpful here, especially points 2 and 3 which correspond to parts 2 and 3 of the formula.
The range where the lookup value is located. Remember that the lookup value should always be in the first column in the range for VLOOKUP to work correctly. For example, if your lookup value is in cell C2 then your range should start with C.
The column number in the range that contains the return value. For example, if you specify B2: D11 as the range, you should count B as the first column, C as the second, and so on.
So change the second D to V in your lookup range, and change the column to 19 instead of 22 - D is the 1st column, E the second and so on till V, the 19th column of the lookup range.
=VLOOKUP(K3,'Sheet1 (2)'!D2:V896,19,FALSE)
if VLOOKUP is not your thing, consider INDEX/MATCH.
=INDEX('Sheet1 (2)'!V:V,MATCH(K3,'Sheet1 (2)'!D:D,0))
=VLOOKUP(K3,Sheet1!D3:E8,2,FALSE)
In formula second last argument is the column number of values.

in excel check a column with text value if true return numeric value in next column

I have two columns, A, B and C,
Column A has two text values "Petrol" & "Butane"
column B has just numeric values (i.e their cost in USD)
I need to run a formula in column C so i can check column A for "Petrol" and check corresponding rows in Column B for their value and then get a SUM of those numeric values as a total cost in column C
Any help would be appreciated!
Thanks
=SUMIF(A:A,"Petrol",B:B)
And
=SUMIF(A:A,"Butane",B:B)
Any cell you put this in will return the sum of all cells in column B where the value on the same row but in column A is equal to the word.
You can use the ISTEXT function
=ISTEXT(A2) Checks to see if cell A2 has text (TRUE)

excel formula : Find uniques in one column depending on value of another column

I can do this manually but I'm sure there is a formulaic way to do this.
Here is the data :
Column-A Column-B Column-C
C Y
D
E Y
F
E Y
What I want to do is in 2 steps :
a.) Select all values in Column-A, where the corresponding value in Column-B is "Y".
b.) From the data selected from Column-A above, select only the unique values and put them in Column-C
c.) Hence the data in Column-C for the above data will be "C" & "E"
Any pointers ?
Here's one option assuming you have excel 2007
Put this formula in C1
=IFERROR(INDEX(A1:A5,MATCH("Y",B1:B5,0)),"")
then this one in C2 copied down
=IFERROR(INDEX(A$1:A$5,MATCH(1,INDEX((B$1:B$5="y")*(COUNTIF(C$1:C1,A$1:A$5)=0),0),0)),"")
You can do it in earlier versions but it requires some longer formulas to ensure that you don't get error values once valid matches are exhausted
Explanation:
Formula 1 uses MATCH to find the position of the first "y" in B1:B5, then INDEX returns the relevant value from A1:A5. If your columns were the other way round you could use VLOOKUP, INDEX/MATCH is a standard way to do a "left lookup".
Formula 2 uses MATCH to find the position of the first row where 2 conditions are satisfied, B1:B5 = "y" and A1:A5 <> a value already found. The values already found are in column C above so the COUNTIF function looks at the cells above and does a count for each value in column A within that range above (which expands as you drag the formula down) - a count of zero means that that value hasn't already been selected. Once MATCH identifies the row number INDEX takes the value from that row in column A.

Resources