Index, Match, Max, If

reberryjr

Well-known Member
Joined
Mar 16, 2017
Messages
714
Office Version
  1. 365
Platform
  1. Windows
I'm using this array formula to return the max date where the primary key matches in 2 different worksheets, and it works fine.
{=MAX(IF(Specs!C:C='Info'!C2,Stats!H:H))}

I'm trying to get the value in column J on the Stats sheet, for the same line. I've been looking at this for a few hours. I've googled and googled, searched through this forum and 2 others. While I've found some information, I've not been able to tweak the formula to get the appropriate value. I want the formula to be dynamic if possible, because the data in the Stats sheet is dynamic.

I've tried these formulas, but none of them work:
{=INDEX(Specs!J:J,MAX(MATCH(Specs!C:C='Info'!C:C,Specs!H:H)))}
{=INDEX(Specs!J:J,MATCH(MAX(Specs!H:H),Specs!H:H,0))}
{=INDEX(Specs!J:J,MAX(MATCH(IF(Specs!C:C='Info'!C2,Specs!H:H),Specs!C:C,0)))}

The 2nd formula returns a number, but it's not associated with the correct record.

The end state goal is to enter the formula into the sheet via a macro, but I have to understand how the formula works first. Any help is appreciated.
 
HI,
I have this, and it works fine so far...
=MAX(INDEX(LLN_Data[Reading], MATCH(1, ($M194=LLN_Data[Name]) * ("N/A"<>LLN_Data[Complete Time]), 0)))

LLN_Data[Reading are numbers
LLN_Data[Name is text
LLN_Data[Complete Time is date/time but may be as a text value
Sorry, I hit [POST} grrrrrr


Anyway, it returns the first hit in LLN_Data[Complete Time but as there can be a number of entries here with different days and times, I want to grab the latest.
There are also N/A entries in LLN_Data[Complete Time the raw data (pulled in from a CSV), which would mess up a simple max lookup, hence the criteria to ignore those.

I'm banging my head trying to use max in here. Have even tested with Value in case excel isn't picking that column up as a date, but arrrrgh my head hurts!

Oh, so far, the index and match works without making it an array, and I would like to keep it that way. The data I pull in only a few hundred rows so I can afford the intensity of an array, but I prefer not to. The rest of the book is quite complex and I want to keep it speedy.

Ignore column L, I'm just using that to pull the data from K as a value

Thanks in advance!
 

Attachments

  • max match poser.jpg
    max match poser.jpg
    112.4 KB · Views: 9
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
@ Wad Mabbit

Could you provide a small sample using XL2BB with the expected results added? No formulas, just data and expected results please.
 
Upvote 0
Hi, this is where I want information to land, in the LLN columns (while I'm 'here', this is next on the wishlist)
- How best to add an instance to a sum for each column where "Activity" is in the header row, and the cell content is either a "C", an "S" or "Co". From there, I want to turn it into a percentage of the sum of those columns to get the percentage of attendance for that item, say Activity, or Assessment, or Webinar...

Anyway, here is the main sheet
Tracking TEST.xlsm
AHLMNOPQRSTUVW
1 B1 InductionB1 LLN
2 StudentSort STATUSD1 First ContactD1 Follow-upD1 EnrolledD1 USI emailedD1 LearningD1 ReadingD1 WritingD1 Oral CommD1 NumeracyD1 LLN| Average
3Messed up But laterJo 02|06 Messed up But laterNET213432.6
4Wha HappenedJo 02|06 Wha HappenedNEML    30.6
5Bilbo Baggins[B1] Jo-01PCTYY334433.4
6Frodo Baggins[B1] Jo-02PETYY433423.2
7z       
Tracking
Cell Formulas
RangeFormula
A1A1=COUNTA(M3:M126)
A2A2=VLOOKUP(SUBTOTAL(104,C3:C126),IF(SUBTOTAL(3,OFFSET(C3:C126,ROW(C3:C126)-ROW(C3),0,1)),B3:D127),2,0)
L3:L7L3=IF([@[ Date]]=0,"z", IF(OR(ISBLANK([@Student]),[@[ Manual Sort]]="N",[@[ Manual Sort]]="L"), LEFT([@[ Location]],2) & TEXT([@[ Date]]," DD|MM ") & [@Student], "["& [@[ Course]]&"] "& LEFT([@[ Location]],2) & "-" & TEXT([@[ Manual Sort]],"00") ))
M3:M7M3=IF($G3=trigger_B1,[@[ B1 STATUS]], IF($G3=trigger_B2,[@[ B2 STATUS]],""))
R3:R5,R7R3=IFERROR(INDEX(LLN_Data[Learning], MATCH(1, ([@Student]=LLN_Data[Name]) * ("N/A"<>LLN_Data[Complete Time]), 0)),0)
S3:S5,S7S3=IFERROR(INDEX(LLN_Data[Reading], MATCH(1, ([@Student]=LLN_Data[Name]) * ("N/A"<>LLN_Data[Complete Time]), 0)),0)
T3:T5,T7T3=IFERROR(INDEX(LLN_Data[Writing], MATCH(1, ([@Student]=LLN_Data[Name]) * ("N/A"<>LLN_Data[Complete Time]), 0)),0)
U3:U5,U7U3=IFERROR(INDEX(LLN_Data[Oral Communication], MATCH(1, ([@Student]=LLN_Data[Name]) * ("N/A"<>LLN_Data[Complete Time]), 0)),0)
V3:V5,V7V3=IFERROR(INDEX(LLN_Data[Numeracy], MATCH(1, ([@Student]=LLN_Data[Name]) * ("N/A"<>LLN_Data[Complete Time]), 0)),0)
W3:W7W3=IF(COUNTA(TrackData[@[D1 Learning]:[D1 Numeracy]])=0,0,AVERAGE(TrackData[@[D1 Learning]:[D1 Numeracy]]))
Named Ranges
NameRefers ToCells
Key_Course=Data!$T$3:$T$4M3:M7
tblStudentRecord=Tracking!$E$3:$FO$16L3
trigger_B1=Data!$T$3M3:M7
trigger_B2=Data!$T$4M3:M7


The Sheet the data is from LLN Data follows in the next' reply"
 
Last edited:
Upvote 0
Hi,

Here is the LLN Data, a sheet I paste CSV values into from an LLN testing site

Tracking TEST.xlsm
ABCDEFGHIJKLMNOPQ
1NameLearner IDFirst NameLast NameEmailLearningReadingWritingOral CommunicationNumeracyComplete Time
2Messed up But laterskippedMessed upBut laterX213432020-06-03 09:06:192020-06-03 10:07:10
3Messed up But laterskippedMessed upBut laterX040002020-06-03 10:06:70
4Messed up But laterskippedMessed upBut laterX213322020-06-03 08:06:14
5Wha HappenedskippedWhaHappenedX00000N/A
6Wha HappenedskippedWhaHappenedX00000N/A
7Wha HappenedskippedWhaHappenedX00000N/A
8Wha HappenedskippedWhaHappenedX00000N/A
9Wha HappenedskippedWhaHappenedX00000N/A
10Wha HappenedskippedWhaHappenedX00000N/A
11Wha HappenedskippedWhaHappenedX000032020-06-03 07:06:56
12Bilbo BagginsskippedBilboBagginsX00000N/ABilbo Baggins33443
13Bilbo BagginsskippedBilboBagginsX00000N/A3
14Bilbo BagginsskippedBilboBagginsX334432020-06-01 06:06:04
15Bilbo BagginsskippedBilboBagginsX002432020-06-01 05:06:85
16Bilbo BagginsskippedBilboBagginsX313422020-06-01 03:06:81
17Frodo BagginsskippedFrodoBagginsX321332020-06-10 09:06:49
18Frodo BagginsskippedFrodoBagginsX131302020-06-10 08:06:81
19Frodo BagginsskippedFrodoBagginsX433402020-06-10 08:06:37
LLN Data
Cell Formulas
RangeFormula
L2L2=MAX(VALUE(K2:K4))
L12L12=A12
M12M12=INDEX(LLN_Data[Learning], MATCH(1, ($L12=LLN_Data[Name]) * ("N/A"<>LLN_Data[Complete Time]) * ("N/A"<>LLN_Data[Complete Time]), 0))
O12O12=INDEX(LLN_Data[Writing], MATCH(1, ($L12=LLN_Data[Name]) * ("N/A"<>LLN_Data[Complete Time]) * ("N/A"<>LLN_Data[Complete Time]), 0))
P12P12=INDEX(LLN_Data[Oral Communication], MATCH(1, ($L12=LLN_Data[Name]) * ("N/A"<>LLN_Data[Complete Time]) * ("N/A"<>LLN_Data[Complete Time]), 0))
Q12Q12=INDEX(LLN_Data[Numeracy], MATCH(1, ($L12=LLN_Data[Name]) * ("N/A"<>LLN_Data[Complete Time]) * ("N/A"<>LLN_Data[Complete Time]), 0))
N12N12=INDEX(LLN_Data[Reading], MATCH(1, ($L12=LLN_Data[Name]) * ("N/A"<>LLN_Data[Complete Time]), 0))
N13N13=MAX(INDEX(LLN_Data[Reading], MATCH(1, ($L12=LLN_Data[Name]) * ("N/A"<>LLN_Data[Complete Time]), 0)))
A2:A19A2=TRIM(C2) & " " & TRIM(D2)
 
Upvote 0
And while you are on the case :-)...

How best to add an instance to a sum for each column where "Activity" is in the header row, and the cell content is either a "C", an "S" or "Co". From there, I want to turn it into a percentage of the sum of those columns to get the percentage of attendance for that item, say Activity, or Assessment, or Webinar...

Tracking TEST.xlsm
HMWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACBCCCDCECFCGCHCICJCKCLCMCNCO
1 1 Introduction 2 xxx 3 xxx 4 xxx 5 ccc 6 ccc 7 ddd 8 ddd 9 eee10 fff11 ggg12 Congrats REPORTING
2Student STATUSD1 LLN| AverageD1 ResourcedD1 ActivityD1 WebinarD1 ParticipationD2 ResourcedD2 ActivityD2 WebinarD2ParticipationD3 ResourcedD3 ActivityD3 A| SAQD3 WebinarD3ParticipationD4 ResourcedD4 ActivityD4B| RP / ProjD4C| Skills / ProjD4 WebinarD4MSMWHS200D5 ResourcedD5 ActivityD5A| SAQD5 WebinarD5ParticipationD6 ResourcedD6 ActivityD6 ReviewD6 B| Role PlayD6 WebinarD6 FSKOCM07D7 ResourcedD7 ActivityD7 PosterD7 A| SAQD7 WebinarD7 ParticipationD8 ResourcedD8 ActivityD8 B| ProjD8 WebinarD8 FSKDIG03D9 ResourcedD9 ActivityD9 A| SAQD9 B| Skills / ProjD9 Webinar10 FSKRDG0510 Resourced10 Activity10 A| SAQ10 B| Skills / Proj10 Webinar10 FSKLRG0511 Resourced11 Activity11 A| SAQ11 B| Case Study11 Webinar11 FSKLRG0912 Resourced12 Activity12 Webinar12 ParticipationB1 App| ResultingB1 aX| ReportB1 ActivitiesB1 WebinarsB1 AssessmentsB1 Summary B1 STATUS
3Messed up But laterN2.6             N
4Wha HappenedN0.6            Y01|06 N
5Bilbo BagginsP3.4TESASTER TESRPTERRR TERR TERR TERR TERR TERRR    1P
6Frodo BagginsP3.2TESASTESASTESSASTESSSACoTESSASTESSACoTESSASTESSACoTERRR    1P
Tracking
Cell Formulas
RangeFormula
M3:M6M3=IF($G3=trigger_B1,[@[ B1 STATUS]], IF($G3=trigger_B2,[@[ B2 STATUS]],""))
W3:W6W3=IF(COUNTA(TrackData[@[D1 Learning]:[D1 Numeracy]])=0,0,AVERAGE(TrackData[@[D1 Learning]:[D1 Numeracy]]))
AA3:AA6AA3=IF(AND([@[D1 Activity]]="S",[@[D1 Webinar]]="A"),"S", IF(OR([@[D1 Activity]]="C",[@[D1 Activity]]="F",[@[D1 Activity]]="S",[@[D1 Activity]]="P",[@[D1 Activity]]="A"),"P", "")) &IF(AND([@[D1 Activity]]="N",[@[D1 Webinar]]="N"),"N", IF(OR([@[D1 Activity]]="N",[@[D1 Webinar]]="N"),"!",""))
AE3:AE6AE3=IF(AND([@[D2 Activity]]="S",[@[D2 Webinar]]="A"),"S", IF(OR([@[D2 Activity]]="C",[@[D2 Activity]]="F",[@[D2 Activity]]="S",[@[D2 Activity]]="P",[@[D2 Activity]]="A"),"P", "")) &IF(AND([@[D2 Activity]]="N",[@[D2 Webinar]]="N"),"N", IF(OR([@[D2 Activity]]="N",[@[D2 Webinar]]="N"),"!",""))
AJ3:AJ6AJ3=IF(AND([@[D3 Activity]]="S",[@[D3 Webinar]]="A"),"S", IF(OR([@[D3 Activity]]="C",[@[D3 Activity]]="F",[@[D3 Activity]]="S",[@[D3 Activity]]="P",[@[D3 Activity]]="A"),"P", "")) &IF(AND([@[D3 Activity]]="N",[@[D3 Webinar]]="N"),"N", IF(OR([@[D3 Activity]]="N",[@[D3 Webinar]]="N"),"!",""))
AP3:AP6AP3=IF(AND([@[D3 A| SAQ]]="S",[@[D4B| RP / Proj]]="S",[@[D4C| Skills / Proj]]="S"),"Co", IF(AND([@[D4 Activity]]="S",[@[D4 Webinar]]="A"),"S", IF(OR([@[D4 Activity]]="C",[@[D4 Activity]]="F",[@[D4 Activity]]="S",[@[D4 Activity]]="P",[@[D4 Activity]]="A"),"P", "")) &IF(AND([@[D4 Activity]]="N",[@[D4 Webinar]]="N"),"N", IF(OR([@[D4 Activity]]="N",[@[D4 Webinar]]="N"),"!","")) )
AU3:AU6AU3=IF(AND([@[D5 Activity]]="S",[@[D5 Webinar]]="A"),"S", IF(OR([@[D5 Activity]]="C",[@[D5 Activity]]="F",[@[D5 Activity]]="S",[@[D5 Activity]]="P",[@[D5 Activity]]="A"),"P", "")) &IF(AND([@[D5 Activity]]="N",[@[D5 Webinar]]="N"),"N", IF(OR([@[D5 Activity]]="N",[@[D5 Webinar]]="N"),"!",""))
BA3:BA6BA3=IF(AND([@[D5A| SAQ]]="S",[@[D6 B| Role Play]]="S"),"Co", IF(AND([@[D6 Activity]]="S",[@[D6 Webinar]]="A"),"S", IF(OR([@[D6 Activity]]="C",[@[D6 Activity]]="F",[@[D6 Activity]]="S",[@[D6 Activity]]="P",[@[D6 Activity]]="A"),"P", "")) &IF(AND([@[D6 Activity]]="N",[@[D6 Webinar]]="N"),"N", IF(OR([@[D6 Activity]]="N",[@[D6 Webinar]]="N"),"!","")) )
BG3:BG6BG3=IF(AND([@[D7 Activity]]="S",[@[D7 Webinar]]="A"),"S", IF(OR([@[D7 Activity]]="C",[@[D7 Activity]]="F",[@[D7 Activity]]="S",[@[D7 Activity]]="P",[@[D7 Activity]]="A"),"P", "")) &IF(AND([@[D7 Activity]]="N",[@[D7 Webinar]]="N"),"N", IF(OR([@[D7 Activity]]="N",[@[D7 Webinar]]="N"),"!",""))
BL3:BL6BL3=IF(AND([@[D7 A| SAQ]]="S",[@[D8 B| Proj]]="S"),"Co", IF(AND([@[D8 Activity]]="S",[@[D8 Webinar]]="A"),"S", IF(OR([@[D8 Activity]]="C",[@[D8 Activity]]="F",[@[D8 Activity]]="S",[@[D8 Activity]]="P",[@[D8 Activity]]="A"),"P", "")) &IF(AND([@[D8 Activity]]="N",[@[D8 Webinar]]="N"),"N", IF(OR([@[D8 Activity]]="N",[@[D8 Webinar]]="N"),"!","")) )
BR3:BR6BR3=IF(AND([@[D9 A| SAQ]]="S",[@[D9 B| Skills / Proj]]="S"),"Co", IF(AND([@[D9 Activity]]="S",[@[D9 Webinar]]="A"),"S", IF(OR([@[D9 Activity]]="C",[@[D9 Activity]]="F",[@[D9 Activity]]="S",[@[D9 Activity]]="P",[@[D9 Activity]]="A"),"P", "")) &IF(AND([@[D9 Activity]]="N",[@[D9 Webinar]]="N"),"N", IF(OR([@[D9 Activity]]="N",[@[D9 Webinar]]="N"),"!","")) )
BX3:BX6BX3=IF(AND([@[10 A| SAQ]]="S",[@[10 B| Skills / Proj]]="S"),"Co", IF(AND([@[10 Activity]]="S",[@[10 Webinar]]="A"),"S", IF(OR([@[10 Activity]]="C",[@[10 Activity]]="F",[@[10 Activity]]="S",[@[10 Activity]]="P",[@[10 Activity]]="A"),"P", "")) &IF(AND([@[10 Activity]]="N",[@[10 Webinar]]="N"),"N", IF(OR([@[10 Activity]]="N",[@[10 Webinar]]="N"),"!","")) )
CD3:CD6CD3=IF(AND([@[11 A| SAQ]]="S",[@[11 B| Case Study]]="S"),"Co", IF(AND([@[11 Activity]]="S",[@[11 Webinar]]="A"),"S", IF(OR([@[11 Activity]]="C",[@[11 Activity]]="F",[@[11 Activity]]="S",[@[11 Activity]]="P",[@[11 Activity]]="A"),"P", "")) &IF(AND([@[11 Activity]]="N",[@[11 Webinar]]="N"),"N", IF(OR([@[11 Activity]]="N",[@[11 Webinar]]="N"),"!","")) )
CH3:CH6CH3=IF(AND([@[12 Activity2]]="S",[@[12 Interview]]="A"),"S", IF(OR([@[12 Activity2]]="C",[@[12 Activity2]]="F",[@[12 Activity2]]="S",[@[12 Interview]]="P",[@[12 Interview]]="A"),"P", "")) &IF(AND([@[12 Activity2]]="N",[@[12 Interview]]="N"),"N", IF(OR([@[12 Activity2]]="N",[@[12 Interview]]="N"),"!",""))
CK3:CK6CK3=SUM(COUNTIFS([@[D1 Activity]], {"P","S","Co"}))
CO3:CO6CO3=IF(ISBLANK($G3),"", IF(OR($E3="D",$E3="H"),"-", IF(OR($E3="L",$E3="P"),"!", IF($E3="N","N", IF(AND([@D4MSMWHS200]="Co",[@[D6 FSKOCM07]]="Co",[@[D8 FSKDIG03]]="Co",[@[10 FSKRDG05]]="Co",[@[11 FSKLRG09]]="Co"),"Co", IF(AND(P3="Y",AJ3="S",AP3="S",AU3="S",BA3="S",BG3="S",BL3="S",BR3="S",BX3="S",CD3="S",CH3="S"),"S", "P")&IF(ISBLANK([@[D1 USI emailed]]),"?","")&IF([@[D1 LLN| Average]]=0,"!","") )))))
Named Ranges
NameRefers ToCells
Key_Course=Data!$T$3:$T$4M3:M6
tblStudentRecord=Tracking!$E$3:$FO$16CO3
trigger_B1=Data!$T$3M3:M6
trigger_B2=Data!$T$4M3:M6
 
Upvote 0
Hi, yeah, I had too much caffeine when I pushed ?.

Maybe if you just help me with a formula to return a match to a cell (a vlookup, of say, a name), where that name is repeated in the lookup range. The hit I'm after is that name with the most recent date in another column.

The lookup data is in a table.

The column with dates is [Complete Time]. The name column is [Name) and the column I want to pull a number from is [Reading].

E.g. I'm locating the latest reading literacy score of a candidate.


Thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top