IF, OR, Index, Match, Multiple Criteria

wintye

New Member
Joined
Apr 15, 2013
Messages
15
Hi All,

I hope you're enjoying the weekend.

I wonder if anyone can help with the following formula. I'm trying to pull a date from another table but only if it matches certain criteria.

Table with Data
[TABLE="width: 500"]
<tbody>[TR]
[TD]Unique Identifier[/TD]
[TD]First Name[/TD]
[TD]Last Name[/TD]
[TD]Course[/TD]
[TD]Date[/TD]
[TD]Grade[/TD]
[/TR]
[TR]
[TD]12345[/TD]
[TD]Jane[/TD]
[TD]Doe[/TD]
[TD]Course 1[/TD]
[TD]15/04/2016[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]12345[/TD]
[TD]Jane[/TD]
[TD]Doe[/TD]
[TD]Course 2[/TD]
[TD]17/05/2017[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]12345[/TD]
[TD]Jane[/TD]
[TD]Doe[/TD]
[TD]Course 3[/TD]
[TD]19/01/2018[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]34567[/TD]
[TD]John[/TD]
[TD]Smith[/TD]
[TD]Course 2[/TD]
[TD]10/07/2017[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]34567[/TD]
[TD]John[/TD]
[TD]Smith[/TD]
[TD]Course 3[/TD]
[TD]25/06/2017[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]34567[/TD]
[TD]John[/TD]
[TD]Smith[/TD]
[TD]Course 1[/TD]
[TD]28/10/2016[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]78901[/TD]
[TD]Jane[/TD]
[TD]Smith[/TD]
[TD]Course 3[/TD]
[TD]01/01/2016[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]78901[/TD]
[TD]Jane[/TD]
[TD]Smith[/TD]
[TD]Course 2[/TD]
[TD]01/10/2017[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]78901[/TD]
[TD]Jane[/TD]
[TD]Smith[/TD]
[TD]Course 1[/TD]
[TD]01/05/2015[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]John[/TD]
[TD]Doe[/TD]
[TD]Course 2[/TD]
[TD]29/03/2015[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]John[/TD]
[TD]Doe[/TD]
[TD]Course 1[/TD]
[TD]23/10/2017[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]John[/TD]
[TD]Doe[/TD]
[TD]Course 3[/TD]
[TD]16/03/2016[/TD]
[TD]7[/TD]
[/TR]
</tbody>[/TABLE]

Table pulling data into

[TABLE="width: 500"]
<tbody>[TR]
[TD]Last Name[/TD]
[TD]First Name[/TD]
[TD]Unique Identifier[/TD]
[TD]Course 1[/TD]
[TD]Course 2[/TD]
[TD]Course 3[/TD]
[/TR]
[TR]
[TD]VLOOKUP from another table[/TD]
[TD]VLOOKUP from another table[/TD]
[TD]VLOOKUP from another table[/TD]
[TD]to include the formula[/TD]
[TD]to include the formula[/TD]
[TD]to include the formula[/TD]
[/TR]
</tbody>[/TABLE]

The formula I have so far is:

{=IF(C2="","",IF(OR(Data_Report[Grade]="3",Data_Report[Grade]="4"),INDEX(Data_Report[Date],MATCH(1,(Data_Report[Unique Identifier]=C2)*(Data_Report[Course]="1"),0)),"Not Applicable"))}

Basically I'd like the formula to show if there's nothing in the "unique Identifier" column then to leave the cell empty,
If there is a "unique Identifier" in cell 'C2' then to lookup the unique identifier to the data table ensuring to match the grade to either a grade 3 or 4 and additionally match the the course name and pulling through the date the course was completed.
If the grade is different to 3 or 4 then to return 'not applicable'

e.g. = Jane Doe, Course 2 should show as '17/05/2017'
John Smith, Course 3 should show as 'Not Applicable'
Jane Smith, Course 1 should show as '01/05/2015'
John Doe, Course 1 should show as a blank cell

Hoping the above makes sense and welcome any feedback and advise. I've spen forever trying to get it to work and am so close but haven't quite got it.

Many thanks in advance for reading
Wintye :confused::confused:
****** id="cke_pastebin" style="position: absolute; top: 0px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">[TABLE="width: 500"]
<tbody>[TR]
[TD]17/05/2017[/TD]
[/TR]
</tbody>[/TABLE]
</body>
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Have a go with:

=IF(C2="","",IF(OR(INDEX(Data_Report[Grade],MATCH(1,INDEX((Data_Report[Unique Identifier]=C2)*(Data_Report[Course]=D$1),0),0))={3,4}),INDEX(Data_Report[Date],MATCH(1,INDEX((Data_Report[Unique Identifier]=C2)*(Data_Report[Course]=D$1),0),0)),"Not Applicable"))
 
Upvote 0
Maybe the Array Formula (use Ctrl+Shift+Enter to enter the formula) below:

In D2 and copy down and to the right:

=IF($C2="","",IFERROR(LOOKUP(1,1/((Data_Report[Unique Identifier]=$C2)*
((Data_Report[Grade]=3)+(Data_Report[Grade]=4))*(Data_Report[Course]=D$1)),Data_Report[Date]),"Not Applicable"))

Markmzz
 
Upvote 0
.. yet another slight variation.
The formula in D2 must be Copy/Pasted (not dragged) across to E2:F2 before being copied (or dragged) down.
[An alternative is to enter my D2 formula as an array formula - as markmzz did with his - which could then be dragged across & down but the array entry makes my formula somewhat slower to calculate]

Excel Workbook
ABCDEF
1Last NameFirst NameUnique IdCourse 1Course 2Course 3
2SmithJane789011/05/20151/10/20171/01/2016
3DoeJane1234515/04/201617/05/201719/01/2018
4DoeJohn
5SmithJohn34567Not ApplicableNot ApplicableNot Applicable
6
7
8Unique IdentifierFirst NameLast NameCourseDateGrade
912345JaneDoeCourse 115/04/20163
1012345JaneDoeCourse 217/05/20173
1112345JaneDoeCourse 319/01/20183
1234567JohnSmithCourse 210/07/20175
1334567JohnSmithCourse 325/06/20175
1434567JohnSmithCourse 128/10/20165
1578901JaneSmithCourse 31/01/20164
1678901JaneSmithCourse 21/10/20174
1778901JaneSmithCourse 11/05/20153
18JohnDoeCourse 229/03/20157
19JohnDoeCourse 123/10/20177
20JohnDoeCourse 316/03/20167
21
Course Date
 
Upvote 0
Maybe the Array Formula (use Ctrl+Shift+Enter to enter the formula) below:

In D2 and copy down and to the right:

=IF($C2="","",IFERROR(LOOKUP(1,1/((Data_Report[Unique Identifier]=$C2)*
((Data_Report[Grade]=3)+(Data_Report[Grade]=4))*(Data_Report[Course]=D$1)),Data_Report[Date]),"Not Applicable"))

Markmzz

Thank you all so much for your help.

Markmzz - Yours works very well.

However I also need for it to tell me if a grade 3 or 4 hasn't completed the course.

At the moment if their unique identifier isn't showing on the report (which it won't as not completed) for that particular course (course 3 for example) then at the moment it just goes straight to "Not Applicable" and I need to to say "Due". I do have a another sheet with all unique identifiers listed with grade.

Is there a way this can also be incorporated?

Thank you so much for your help so far, It's really appreciated

Wintye
 
Upvote 0
Markmzz - Yours works very well.

However I also need for it to tell me if a grade 3 or 4 hasn't completed the course.

At the moment if their unique identifier isn't showing on the report (which it won't as not completed) for that particular course (course 3 for example) then at the moment it just goes straight to "Not Applicable" and I need to to say "Due". I do have a another sheet with all unique identifiers listed with grade.

Is there a way this can also be incorporated?

Thank you so much for your help so far, It's really appreciated

Wintye

Hi Wintye,

I'm sorry, but I didn't understand what you want.

Could you put an example (like placed in your post #01) in your next post? With more details (what you have and what you want).

Markmzz
 
Last edited:
Upvote 0

Hi Wintye,

I'm sorry, but I didn't understand what you want.

Could you put an example (like placed in your post #01) in your next post? With more details (what you have and what you want).

Markmzz

Hi Markmzz,

Thanks so much for your reply.

At the moment I have a colleague that is grade 4 and pulled through on the report for two of the courses but not the final report due to it's not yet been completed. I need the formula to show that that person hasn't completed and is still due - due to being a grade 4.

Table with Data
[TABLE="class: cms_table, width: 500"]
<tbody>[TR]
[TD]Unique Identifier[/TD]
[TD]First Name[/TD]
[TD]Last Name[/TD]
[TD]Course[/TD]
[TD]Date[/TD]
[TD]Grade[/TD]
[/TR]
[TR]
[TD]12345[/TD]
[TD]Jane[/TD]
[TD]Doe[/TD]
[TD]Course 1[/TD]
[TD]15/04/2016[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]12345[/TD]
[TD]Jane[/TD]
[TD]Doe[/TD]
[TD]Course 2[/TD]
[TD]17/05/2017[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]34567[/TD]
[TD]John[/TD]
[TD]Smith[/TD]
[TD]Course 2[/TD]
[TD]10/07/2017[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]34567[/TD]
[TD]John[/TD]
[TD]Smith[/TD]
[TD]Course 3[/TD]
[TD]25/06/2017[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]34567[/TD]
[TD]John[/TD]
[TD]Smith[/TD]
[TD]Course 1[/TD]
[TD]28/10/2016[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]78901[/TD]
[TD]Jane[/TD]
[TD]Smith[/TD]
[TD]Course 3[/TD]
[TD]01/01/2016[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]78901[/TD]
[TD]Jane[/TD]
[TD]Smith[/TD]
[TD]Course 2[/TD]
[TD]01/10/2017[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]78901[/TD]
[TD]Jane[/TD]
[TD]Smith[/TD]
[TD]Course 1[/TD]
[TD]01/05/2015[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]John[/TD]
[TD]Doe[/TD]
[TD]Course 2[/TD]
[TD]29/03/2015[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]John[/TD]
[TD]Doe[/TD]
[TD]Course 1[/TD]
[TD]23/10/2017[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]John[/TD]
[TD]Doe[/TD]
[TD]Course 3[/TD]
[TD]16/03/2016[/TD]
[TD]7[/TD]
[/TR]
</tbody>[/TABLE]

As you can see from the above table, Jane Doe is a grade 3 so needs to complete all three courses but is only showing on the data report as having completed course 1 & course 2. Course 3 won't show on this report until it's completed.

I need the formula (that's pulling this data from the data report into another sheet) to also advise that as that person is a grade 3 (or 4) and that course isn't listed then to show as due to show that it still needs to be completed.

Hopefully the above helps a little but let me know if not.

Many thanks
Wintye
 
Upvote 0
Hi Markmzz,

Thanks so much for your reply.

At the moment I have a colleague that is grade 4 and pulled through on the report for two of the courses but not the final report due to it's not yet been completed. I need the formula to show that that person hasn't completed and is still due - due to being a grade 4.

As you can see from the above table, Jane Doe is a grade 3 so needs to complete all three courses but is only showing on the data report as having completed course 1 & course 2. Course 3 won't show on this report until it's completed.

I need the formula (that's pulling this data from the data report into another sheet) to also advise that as that person is a grade 3 (or 4) and that course isn't listed then to show as due to show that it still needs to be completed.

Hopefully the above helps a little but let me know if not.

Many thanks
Wintye

Hi Wintye,

Do some tests with the Array Formula (use Ctrl+Shift+Enter to enter the formula) below and tell me if it works.

=IF($C2="","",IFERROR(LOOKUP(1,1/((Data_Report[Unique Identifier]=$C2)*
((Data_Report[Grade]=3)+(Data_Report[Grade]=4))*(Data_Report[Course]=D$1)),Data_Report[Date]),
IF(SUM((Data_Report[Unique Identifier]=$C2)*((Data_Report[Grade]=3)+(Data_Report[Grade]=4))),"Due","Not Applicable")))


Markmzz
 
Last edited:
Upvote 0
Hi All,

Me again. Thank you so much for your help previously.

My needs have changed a little since the above and I'm wondering if anyone could help?


Table:


[TABLE="width: 0"]
<tbody>[TR]
[TD]Unique Identifier
[/TD]
[TD]First Name
[/TD]
[TD]Last Name
[/TD]
[TD]Grade
[/TD]
[TD]Status
[/TD]
[TD]Completed On
[/TD]
[TD]+ Years
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Due
[/TD]
[/TR]
[TR]
[TD]12345
[/TD]
[TD]Jane
[/TD]
[TD]Doe
[/TD]
[TD]5
[/TD]
[TD]Not Applicable
[/TD]
[TD][/TD]
[TD]1
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12346
[/TD]
[TD]John
[/TD]
[TD]Doe
[/TD]
[TD]5
[/TD]
[TD]Not Applicable
[/TD]
[TD]13/12/2017
[/TD]
[TD]1
[/TD]
[TD][/TD]
[TD][/TD]
[TD]13/12/2018
[/TD]
[/TR]
[TR]
[TD]12347
[/TD]
[TD]Jane
[/TD]
[TD]Smith
[/TD]
[TD]7
[/TD]
[TD]Not Applicable
[/TD]
[TD]12/11/2017
[/TD]
[TD]1
[/TD]
[TD][/TD]
[TD][/TD]
[TD]23/11/2018
[/TD]
[/TR]
[TR]
[TD]12348
[/TD]
[TD]John
[/TD]
[TD]Smith
[/TD]
[TD]4
[/TD]
[TD]Due
[/TD]
[TD][/TD]
[TD]1
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12349
[/TD]
[TD]Jane
[/TD]
[TD]Jones
[/TD]
[TD]5
[/TD]
[TD]Not Applicable
[/TD]
[TD]11/12/2017
[/TD]
[TD]1
[/TD]
[TD][/TD]
[TD][/TD]
[TD]11/12/2018
[/TD]
[/TR]
[TR]
[TD]12334
[/TD]
[TD]John
[/TD]
[TD]Jones
[/TD]
[TD]4
[/TD]
[TD]Completed
[/TD]
[TD]14/12/2017
[/TD]
[TD]1
[/TD]
[TD][/TD]
[TD][/TD]
[TD]14/12/2018
[/TD]
[/TR]
[TR]
[TD]12335
[/TD]
[TD]Jane
[/TD]
[TD]Doe
[/TD]
[TD]6
[/TD]
[TD]Not Applicable
[/TD]
[TD]02/01/2018
[/TD]
[TD]1
[/TD]
[TD][/TD]
[TD][/TD]
[TD]02/01/2019
[/TD]
[/TR]
[TR]
[TD]12336
[/TD]
[TD]John
[/TD]
[TD]Doe
[/TD]
[TD]5
[/TD]
[TD]Not Applicable
[/TD]
[TD]29/09/2017
[/TD]
[TD]1
[/TD]
[TD][/TD]
[TD][/TD]
[TD]27/09/2018
[/TD]
[/TR]
[TR]
[TD]12337
[/TD]
[TD]Jane
[/TD]
[TD]Smith
[/TD]
[TD]4
[/TD]
[TD]Completed
[/TD]
[TD]27/09/2017
[/TD]
[TD]1
[/TD]
[TD][/TD]
[TD][/TD]
[TD]27/09/2018
[/TD]
[/TR]
[TR]
[TD]12338
[/TD]
[TD]John
[/TD]
[TD]Smith
[/TD]
[TD]3
[/TD]
[TD]Due
[/TD]
[TD][/TD]
[TD]1
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


I need the formula inserted in the Status column to return the values as shown above.

I need this column to show as

"Not Applicable" if the grade is 5 or higher. (Some that are grade 5 or above have completed the course but I need it to ignore that and still show as not available.

"Due" if a Grade 3 or 4 doesn't have a date entered in the 'completed on' column
"Due in 2 wks" if the due column is today's date + 14
"Due in 4 wks" if the due column is today's date + 28
"Expired" if less than Today's Date
"Completed" if the date is within a year (less a month)

Any help would be greatly greatly appreciated.

Thank you in advance
Wintye
 
Upvote 0
Hi All,

Me again. Thank you so much for your help previously.

My needs have changed a little since the above and I'm wondering if anyone could help?


I need the formula inserted in the Status column to return the values as shown above.

I need this column to show as

"Not Applicable" if the grade is 5 or higher. (Some that are grade 5 or above have completed the course but I need it to ignore that and still show as not available.

"Due" if a Grade 3 or 4 doesn't have a date entered in the 'completed on' column
"Due in 2 wks" if the due column is today's date + 14
"Due in 4 wks" if the due column is today's date + 28
"Expired" if less than Today's Date
"Completed" if the date is within a year (less a month)

Any help would be greatly greatly appreciated.

Thank you in advance
Wintye

Hi Wintye!

If I understand correctly what you want now, maybe the suggestion below can help you:

In E2

=IF([@Grade]>4,"Not Applicable",
IF([@[Completed On]]="","Due",
LOOKUP(N([@Due])-TODAY(),{-2958465,"";-3650,"Expired";14,"Due in 2 wks";28,"Due in 4 wks";30,"Completed";366,""})))


[TABLE="class: grid, width: 678"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Unique Identifier[/TD]
[TD]First Name[/TD]
[TD]Last Name[/TD]
[TD]Grade[/TD]
[TD]Status[/TD]
[TD]Completed On[/TD]
[TD]+ Years[/TD]
[TD]Due[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]12345[/TD]
[TD]Jane[/TD]
[TD]Doe[/TD]
[TD]5[/TD]
[TD]Not Applicable[/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]12346[/TD]
[TD]John[/TD]
[TD]Doe[/TD]
[TD]5[/TD]
[TD]Not Applicable[/TD]
[TD]13/12/2017[/TD]
[TD]1[/TD]
[TD]13/12/2018[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]12347[/TD]
[TD]Jane[/TD]
[TD]Smith[/TD]
[TD]7[/TD]
[TD]Not Applicable[/TD]
[TD]12/11/2017[/TD]
[TD]1[/TD]
[TD]23/11/2018[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]12348[/TD]
[TD]John[/TD]
[TD]Smith[/TD]
[TD]4[/TD]
[TD]Due[/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]12349[/TD]
[TD]Jane[/TD]
[TD]Jones[/TD]
[TD]5[/TD]
[TD]Not Applicable[/TD]
[TD]11/12/2017[/TD]
[TD]1[/TD]
[TD]11/12/2018[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]12334[/TD]
[TD]John[/TD]
[TD]Jones[/TD]
[TD]4[/TD]
[TD]Completed[/TD]
[TD]14/12/2017[/TD]
[TD]1[/TD]
[TD]14/12/2018[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]12335[/TD]
[TD]Jane[/TD]
[TD]Doe[/TD]
[TD]6[/TD]
[TD]Not Applicable[/TD]
[TD]02/01/2018[/TD]
[TD]1[/TD]
[TD]02/01/2019[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]12336[/TD]
[TD]John[/TD]
[TD]Doe[/TD]
[TD]5[/TD]
[TD]Not Applicable[/TD]
[TD]29/09/2017[/TD]
[TD]1[/TD]
[TD]27/09/2018[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]12337[/TD]
[TD]Jane[/TD]
[TD]Smith[/TD]
[TD]4[/TD]
[TD]Completed[/TD]
[TD]27/09/2017[/TD]
[TD]1[/TD]
[TD]27/09/2018[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]12338[/TD]
[TD]John[/TD]
[TD]Smith[/TD]
[TD]3[/TD]
[TD]Due[/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]****[/TD]
[TD]****************[/TD]
[TD]***********[/TD]
[TD]************[/TD]
[TD]*******[/TD]
[TD]*****************[/TD]
[TD]***************[/TD]
[TD]********[/TD]
[TD]************[/TD]
[/TR]
</tbody>[/TABLE]

Markmzz
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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