Excel - INDEX/MATCH with MAX and Criteria - Boolean logic - excel

Please see screen grab. I am using Excel 2010. My result is needed in cell G4 which I will fill down to G14.
I am looking at the left table to match "Swindon" and the MAX value of "Net". So in this example, I would expect the result to be "Walters" from the "Name" column.
I am attempting to use two INDEX and a MATCH with some boolean logic on the two internal arrays on the second INDEX where it matches 1. However I cannot seem to get this formula working. Where am I going wrong? Please note: I am avoiding an array formula.
Thanks for looking.

If the values are unique as you say then you could use MAXIFS, INDEX and MATCH:
=INDEX(B:B,MATCH(MAXIFS(D:D,C:C,F4),D:D,0))
Find the max value where Swindon is in column C then use this value in index match.
2010 version would be AGGREGATE instead of MAXIFS:
=INDEX(B:B,MATCH(AGGREGATE(14,6,D:D/(C:C=F4),1),D:D,0))

With Excel2010 try below array formula-
=IFERROR(INDEX(Table6[Name],MATCH(MAX(IF(Table6[Location]=[#City],Table6[Net],""))&[#City],Table6[Net]&Table6[Location],0)),"")
Press CTRL+SHIFT+ENTER to evaluate the formula as it is an array formula.
With Excel365 you can try-
=#IFERROR(SORT(FILTER(Table6,Table6[Location]=[#City]),3,-1),"")

Related

Using an Excel formula to read a date corresponding to a cell

Please see the screenshot of my schedule below.
I need a formula that will populate the END_DATE column with the date corresponding to the very last (rightmost) 'x' for each row..
Is there a way to read the rightmost 'x' in a row, and populate a cell with the date above that 'x'?
Any help is much appreciated.
Thanks,
PJ
Updated based on #Dan's very correct feedback
You can use Array/CSE formula:
=INDEX($E$4:$K$4, 1, MAX(IF(E5:K5="X",COLUMN(E5:K5)-(COLUMN(E5)-1))))
Using Ctrl+Shift+Enter to enter that in. This will find the max column number that contains an X and subtract 3 from it (assuming the range we are searching is D2:J2, otherwise the -3 will have to be adjusted to compensate. Then using Index() to find the corresponding value for that column.
as an alternative to an array or CSE formula you can use aggregate which performs array like operations within the aggregate function. Adjust the references to suit your needs, but avoid using full row/column references within aggregate due to the array like calculations it performs.
This solution uses a combination of INDEX and AGGREGATE
=INDEX($4:$4,AGGREGATE(14,6,COLUMN($E5:$K5)/($E5:$K5="x"),1))
I used the above formula in the yellow cells shown in the example below.

Using a vlookup or index match inside a sumproduct function

I have two 2-D arrays that relate to engines. The first table classifies an Engine as either a or as b. The second table has a numerical count value for each of the engines.
I want to calculate the number of engines for each label. Here, label a has a count of 40 and label b has a count of 300.
I thought the following formula would work...
=SUMPRODUCT(
--(E3=VLOOKUP(A11:A17,A2:B8,2,0)),
B11:B17
)
...but it does not!
Why can't I use a vlookup inside a sumproduct array formula? Index-match also doesn't work.
I can't append a new column to the second table with a vlookup forumla that references the first table.
Use LOOKUP:
=SUMPRODUCT(($B$2:$B$8=E3)*LOOKUP($A$2:$A$8,$A$11:$A$17,$B$11:$B$17))
To do it with unsorted data use this array formula:
=SUM(SUMIF($A$11:$A$17,IF($B$2:$B$8=E3,$A$2:$A$8),$B$11:$B$17))
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.

Microsoft Excel - for each unique value in column A, return max value from column C and the corresponding value from B

using a formula, I'm looking to get the max of column C for each unique value in column A then I'd like to also return the corresponding value from column B to the max of column C. the output should be a summary of the data as in the second screen capture. I've tried pivot tables, conditional formatting and the help in this link with no luck Get the maximum values of column B per each distinct value of column A
original data
desired result
Is this possible with formulas?
So for the Max number use the AGGREGATE() Function:
=AGGREGATE(14,6,$C$2:INDEX(C:C,MATCH(1E+99,C:C))/($A$2:INDEX(A:A,MATCH(1E+99,C:C))=I2),1)
Then to find the Capacity a simple SUMIF():
=SUMIFS(B:B,A:A,I2,C:C,K2)
The AGGREGATE() Function was introduced in Excel 2010.
For other versions, the less robust Array Formula MAX(IF()) will work in place of the AGGREGATE:
=MAX(IF($A$2:INDEX(A:A,MATCH(1E+99,C:C))=I2,$C$2:INDEX(C:C,MATCH(1E+99,C:C))))
Being an Array Formula it must be confirmed with Ctrl-Shift-Enter when exiting Edit mode. When done correctly Excel will automatically put {} around the formula to denote an array formula.
Another, If you have the latest Office 365 or using the online app the following non CSE MAXIFS() will work also:
=MAXIFS($C$2:INDEX(C:C,MATCH(1E+99,C:C)),$A$2:INDEX(A:A,MATCH(1E+99,C:C)),I2)
These two are not as robust as the AGGREGATE() in that they will break if there are errors in the data. AGGREGATE() will ignore them.
Here's another option using Array formula, in a Table. I didn't do this starting at A1 in my sheet, so the image has my cell/row IDs to assist!
Cell M17: =IFNA(INDEX([Host], MATCH(0, COUNTIF($M$16:M16, [Host]), 0)),"Unknown") +Ctrl+Shift+Enter
Cell N17: =MAX(IF([Host]=[#UniqueHost],[Duration])) +Ctrl+Shift+Enter
Cell O17: =IFNA(INDEX([Capacity],MATCH([#UniqueHost]&[#MaxDuration],[Host]&[Duration],0)),0) +Ctrl+Shift+Enter

SUMIF with several OR criteria

The blue cell summates to 1, but that is not correct and it should summate to more because of the row text match with B47 row. Any ideas what's wrong?
SUMIF is not supposed to work with more than one criteria (you can't check multiple criteria within one SUMIF as you tried in your formula).
This formula will calculate the right result for you: =SUM(B3:BI3*(IFERROR(MATCH(B2:BI3,B47:AL47,0)>0,0))), this is an array formula, so you need to press CTRL+SHIFT+ENTER after it.
MATCH(...): look for all students whether they are in the list with requirments (this is the part which works only as array formula)
IFERROR(...): converts #N/A errors to 0
If I am not wrong, you are trying to calculate the number of students for a particular project with skill1 and skill2.
You may also try using COUNTIFS() function. This works for multiple criteria.

Find MIN/MAX date in a range if it matches criteria of other columns

Column A is date
Column B is criteria
I want to find the MIN date for each criteria. I tried using Ctrl+Shift+Enter with
=MIN(MATCH(B2,B:B,0))
but thats not quite right because I need to refer to Column A somehow to get the date. I'm pretty confident this can be done with arrays, so any help would be great.
Try this (array formula):
=MIN(IF(B2=B:B,A:A))
An even more compact array formula is:
=MINIF(B2=B:B,A:A)
NOTE 1: Complete using Ctrl+Shift+Enter to enter the formula as an array formula.
NOTE 2: The two-formula method (i.e., using =MIN(IF(B2=B:B,A:A))) is more flexible and works in more cases than the single-formula method shown here but I've included it as an answer as a possible option.
=SMALL(INDEX(($F$2:$F$14=F3)*$D$2:$D$14,),SUM(COUNTA(F:F)-COUNTIF(F:F,F3)))
If your criteria is repeated and want to find the min date for that you can use this without shift+ctrl + enter function.
date is D column
criteria is F column

Resources