title: Excel , if function, ifs,
body: <pre><code>I assume x is the number I'm going to analyze and "y" is as "male" or "female" and "z" is as age group.
  </code></pre>
  
  <p>x is a number that the result will be "underweight", healthy " or overweight". but x which is actually the BPI is not the same for male and female. eg, if x = 21 then depends on gender and age it would be categorized as either "underweigh", "healthy " or overweight".</p>
  
  <pre><code> Function BAI(x As Integer, y As String, z As Integer) As String
  
  
   If x &lt; 21 And y = "female" And 20 &lt;= z &lt;= 39 Then
      BAI = "UNDERWEIGHT"
  
   Elseif 22 &lt;= x &lt;= 33 And y = "Female" And 20 &lt;= z &lt;= 39 Then
      BAI = "Healthy"
  
  ElseIf 34 &lt;= x &lt;= 38 And y = "Female" And 20 &lt;= z &lt;= 39 Then
      BAI = "overweight"
  
  ElseIf x &gt;= 39 And y = "Female" And 20 &lt;= z &lt;= 39 Then
      BAI = "OBESE"
  
  ElseIf x &lt;= 23 And y = "female" And 40 &lt;= z &lt;= 59 Then
      BAI = "UNDERWEIGHT"
  
  ElseIf 24 &lt;= x &lt;= 35 And y = "female" And 40 &lt;= z &lt;= 59 Then
      BAI = "Healthy"
  
  ElseIf 36 &lt;= x &lt;= 41 And y = "female" And 40 &lt;= z &lt;= 59 Then
      BAI = "Overweight"
  
  ElseIf x &gt;= 42 And y = "female" And 40 &lt;= z &lt;= 59 Then
      BAI = "OBESE"
  
  ElseIf x &lt;= 25 And y = "female" And 60 &lt;= z &lt;= 79 Then
      BAI = "UNDERWEIGHT"
  
  ElseIf 26 &lt;= x &lt;= 38 And y = "female" And 60 &lt;= z &lt;= 79 Then
      BAI = "Healthy"
  
  ElseIf 39 &lt;= x &lt;= 43 And y = "female" And 60 &lt;= z &lt;= 79 Then
      BAI = "Overweight"
  
  ElseIf x &gt;= 44 And y = "female" And 60 &lt;= z &lt;= 79 Then
      BAI = "obese"
  
  ElseIf x &lt;= 8 And y = "male" And 20 &lt;= z &lt;= 39 Then
      BAI = "Underweight"
  
  ElseIf 9 &lt;= x &lt;= 21 And y = "male" And 20 &lt;= z &lt;= 39 Then
      BAI = "Healthy"
  
  ElseIf 22 &lt;= x &lt;= 26 And y = "male" And 20 &lt;= z &lt;= 39 Then
      BAI = "overweight"
  
  ElseIf x &gt;= 27 And y = "male" And 20 &lt;= z &lt;= 39 Then
      BAI = "OBESE"
  
  ElseIf x &lt;= 11 And y = "male" And 40 &lt;= z &lt;= 59 Then
      BAI = "UNDERWEIGHT"
  
  ElseIf 12 &lt;= x &lt;= 23 And y = "male" And 40 &lt;= z &lt;= 59 Then
      BAI = "Healthy"
  
  ElseIf 24 &lt;= x &lt;= 28 And y = "male" And 40 &lt;= z &lt;= 59 Then
      BAI = "Overweight"
  
  ElseIf x &gt;= 29 And y = "male" And 40 &lt;= z &lt;= 59 Then
      BAI = "OBESE"
  
  ElseIf x &lt;= 13 And y = "male" And 60 &lt;= z &lt;= 79 Then
      BAI = "UNDERWEIGHT"
  
  ElseIf 14 &lt;= x &lt;= 25 And y = "male" And 60 &lt;= z &lt;= 79 Then
      BAI = "Healthy"
  
  ElseIf 26 &lt;= x &lt;= 30 And y = "male" And 60 &lt;= z &lt;= 79 Then
      BAI = "Overweight"
  
   End If
  
   End Function
  </code></pre>