Not sure what function to use here: IF OR AND INDEX MATCH?

slam

Well-known Member
Joined
Sep 16, 2002
Messages
871
Office Version
  1. 365
  2. 2019
Hi gang! Hope everyone is having an amazing day.

Mock scenario to mirror what I'm looking for:

I have two worksheets, Sheet1, Sheet2.

Sheet1 has a list of teams in column A where each team is listed only once:

Team1
Team2
Team3
Team4

Sheet2 lists the roles within the teams where the team name is in column A again, and the role is in column B. Example:

Team1 | Expert-J
Team1 | Manager
Team1 | Programmer
Team2 | Manager
Team3 | Expert-J
Team3 | Expert
Team4 | Assessor
Team4 | Expert

What I am looking for is on Sheet1, I need the following displayed based on the above values:

Team1 | Expert & Non-Expert
Team2 | Non-Expert
Team3 | Expert
Team4 | Expert & Non-Expert

In other words, I need to look for the word Expert on Sheet2 within each Team, and see if it's the only role on a team (display "Expert"), if there's no instances of the word (display "Non-Expert"), or if there's an Expert along with other roles (display "Expert & Non-Expert")

Massively appreciate any help on this! <3
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
This should work for Excel 365:

Book1
AB
1Teams
2Team1Expert & Non-expert
3Team2Non-expert
4Team3Expert
5Team4Expert & Non-expert
6
Sheet1
Cell Formulas
RangeFormula
B2:B5B2=LET(ex,COUNTIFS(Sheet2!A:A,A2,Sheet2!B:B,"*expert*"),ne,COUNTIF(Sheet2!A:A,A2)-ex,IF(ex>0,"Expert","")&IF(AND(ex>0,ne>0)," & ","")&IF(ne>0,"Non-expert",""))


I'll see about getting something for 2019.
 
Upvote 0
Solution
This works in 2019:

Excel Formula:
=TEXTJOIN(" & ",1,CHOOSE({1,2},IF(COUNTIFS(Sheet2!A:A,A2,Sheet2!B:B,"*expert*"),"Expert",""),IF(COUNTIF(Sheet2!A:A,A2)-COUNTIFS(Sheet2!A:A,A2,Sheet2!B:B,"*expert*"),"Non-expert","")))
 
Upvote 0
365 only

MrExcelPlayground13.xlsx
ABCD
1Sheet 1Sheet 2
2Team1Team1 | Expert & Non-ExpertTeam1 | Expert-J
3Team2Team2 | Non-ExpertTeam1 | Manager
4Team3Team3 | ExpertTeam2 | Programmer
5Team4Team4 | Expert & Non-ExpertTeam2 | Manager
6Team3 | Expert-J
7Team3 | Expert
8Team4 | Assessor
9Team4 | Expert
Sheet16
Cell Formulas
RangeFormula
B2:B5B2=LET(a,A2,b,$D$2:$D$9,c,NOT(ISERR(SEARCH(a,b))),d,FILTER(b,c),e,ISERR(SEARCH("Expert",d)),f,SUM(--e)+1,a&" | "&CHOOSE(f,"Expert","Expert & Non-Expert","Non-Expert"))
 
Upvote 0
This should work for Excel 365:

Book1
AB
1Teams
2Team1Expert & Non-expert
3Team2Non-expert
4Team3Expert
5Team4Expert & Non-expert
6
Sheet1
Cell Formulas
RangeFormula
B2:B5B2=LET(ex,COUNTIFS(Sheet2!A:A,A2,Sheet2!B:B,"*expert*"),ne,COUNTIF(Sheet2!A:A,A2)-ex,IF(ex>0,"Expert","")&IF(AND(ex>0,ne>0)," & ","")&IF(ne>0,"Non-expert",""))


I'll see about getting something for 2019.

Thank you so much, initial checks show this works perfectly!
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,487
Members
448,967
Latest member
visheshkotha

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