newparadigmz
asked on
Excel Array formula Index/Match based on Max value
In attached, top table should match the values of bottom table.
I know I'm mostly right, but can't crack it.
QueryTable.xlsm
I know I'm mostly right, but can't crack it.
QueryTable.xlsm
.......no actually I see you won't get the right results for column P, so you need this version for P18 copied down
=INDEX(otr!$A$3:$I$42,MATC H(MAX(IF($ A$3:$A$42= $M18,$E$3: $E$42)),$E $3:$E$42,0 ),MATCH(ot r!P$17,otr !$A$1:$I$1 ,0))
Note that if you take the max date for "Issue" and the max date for "Maturity" theoretically they might not belong to the same row. My suggested N18 formula just matches the max Issue date - if you want you can match both with this version
=INDEX(otr!$A$3:$I$42,MATC H(1,($D$3: $D$42=$O18 )*($E$3:$E $42=$P18)* ($A$3:$A$4 2=$M18),0) ,MATCH(otr !N$17,otr! $A$1:$I$1, 0))
In this sample it gives you the same results as the previously suggested N18 formula, but depending on your data it may not do so (and may even return #N/A if there is no matching row).
regards, barry
=INDEX(otr!$A$3:$I$42,MATC
Note that if you take the max date for "Issue" and the max date for "Maturity" theoretically they might not belong to the same row. My suggested N18 formula just matches the max Issue date - if you want you can match both with this version
=INDEX(otr!$A$3:$I$42,MATC
In this sample it gives you the same results as the previously suggested N18 formula, but depending on your data it may not do so (and may even return #N/A if there is no matching row).
regards, barry
newparadigmz,
The attached has two versions. The first (yellow) uses a helper column ("Row") to find the relevant row...
Brian.QueryTable-V2.xlsm
The attached has two versions. The first (yellow) uses a helper column ("Row") to find the relevant row...
=OFFSET($A$1,$Q18-1,MATCH(N$17,$A$1:$I$1,0)-1)
...and the helper...
{=MIN(IF($A$3:$A$42&":"&$D$3:$D$42=$M18&":"&MAX(IF($A$3:$A$42=$M18,$D$3:$D$42)),ROW($A$3:$A$42),9^10))}
The second version (red) doesn't use a helper...
=OFFSET($A$1,MIN(IF($A$3:$A$42&":"&$D$3:$D$42=$M38&":"&MAX(IF($A$3:$A$42=$M38,$D$3:$D$42)),ROW($A$3:$A$42),9^10))-1,MATCH(N$17,$A$1:$I$1,0)-1)
Regards,Brian.QueryTable-V2.xlsm
ASKER
@barry, you were right on the first count, only based off max of Issue, but you're not using max formula? also, when I apply it to other fields, getting circular reference errors.
@redmond, yours works consistently, but do you think it's possible to just use index/match/max combo, like what I was trying to attempt?
@redmond, yours works consistently, but do you think it's possible to just use index/match/max combo, like what I was trying to attempt?
newparadigmz,
I'm sorry that mine wasn't what you wanted, but, trust me, it would be a complete waste of your time and mine to work on it while Barry's involved!
Regards,
brian.
I'm sorry that mine wasn't what you wanted, but, trust me, it would be a complete waste of your time and mine to work on it while Barry's involved!
Regards,
brian.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
newparadimz,
Which version of Excel are you using?
If the answer is Excel 2010 or later, then you can use the AGGREGATE function. It will let you create a formula that has the benefits of Boolean expressions without needing to be array-entered. Here is a formula for P18 that you may copy both across and down:
=AGGREGATE(14,6,INDEX(otr! $A$3:$I$42 ,,MATCH(P$ 17,otr!$A$ 1:$I$1,0)) /(otr!$A$3 :$A$42=$M1 8),1)
The first parameter (14) means to find the largest values. The last parameter (1) means to find the first largest value. The combination is equivalent to MAX. The second parameter (6) means to ignore error values (the Boolean expression returns an error value if no match in column A for M18).
Brad
Which version of Excel are you using?
If the answer is Excel 2010 or later, then you can use the AGGREGATE function. It will let you create a formula that has the benefits of Boolean expressions without needing to be array-entered. Here is a formula for P18 that you may copy both across and down:
=AGGREGATE(14,6,INDEX(otr!
The first parameter (14) means to find the largest values. The last parameter (1) means to find the first largest value. The combination is equivalent to MAX. The second parameter (6) means to ignore error values (the Boolean expression returns an error value if no match in column A for M18).
Brad
ASKER
@ barry, yes!, last formula works perfect!
The circular reference was because formula should look in the main data table, and copied across, so when I put it in O18, it referenced itself.
While I don't fully understand the Match nesting, I can 'see' that it is acting on the max of Issue date and lookup value.
@ red, yours also works perfect, just less intuitive for me to understand.
@ byundt, thanks, using 2007, but good to know!
The circular reference was because formula should look in the main data table, and copied across, so when I put it in O18, it referenced itself.
While I don't fully understand the Match nesting, I can 'see' that it is acting on the max of Issue date and lookup value.
@ red, yours also works perfect, just less intuitive for me to understand.
@ byundt, thanks, using 2007, but good to know!
=INDEX(otr!$A$3:$I$42,MATC
confirmed with CTRL+SHIFT+ENTER and copied down column
regards, barry