title: Index/Match with IF Statement
body: <p><a href="https://i.stack.imgur.com/cl5jt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cl5jt.png" alt="enter image description here"></a></p>
  
  <p>As you can see, I have a database table on the left. And I want to add in IF statement that allows me to lookup the [Code], [Name] and [Amount] of the top 5 of Company A ONLY. Then do a top 5 for Company B and so on. I have managed to lookup the top 5 out of ALL companies but cannot seem to add a criteria to target specific company.</p>
  
  <p>Here are my formulas so far:</p>
  
  <p>Formula in Column K [Company]: = <code>INDEX(Database,MATCH(N3,sales,0),1)</code></p>
  
  <p>Formula in Column L [Code]: = <code>INDEX(Database,MATCH(N3,sales,0),2)</code></p>
  
  <p>Formula in Column M [Name]: = <code>INDEX(Database,MATCH(N3,sales,0),2)</code></p>
  
  <p>Formula in Column N [Amount]: = <code>LARGE(sales,ROW(1:20))</code></p>
  
  <p>The intended result is to show the top 5 sales person in each company along with their [Code], [Name] and [Amount], feel free to suggest any edits to the worksheet.</p>