Question: I'm trying to use an AND operator inside MAX and IF functions and am having trouble. I want to find the maximum value from column C where both are true:

* column A = $D$1
* the max only considers the top 80% of the values in column B

So in the example below, the answer would be 7, since of the rows with column A = "foo" and the top 80% of column B which are 3,4,5,6 the max value is 7.

I have two components working:

```
=MAX(IF($A$1:$A$12=$D$1,$C$1:$C$12))

```

returns 12

```
=MAX(IF(B1:B12>PERCENTILE(B1:B12,0.2),C1:C12))

```

returns 8

If I put them together like this it returns 0 (even with ctrl+shift+enter):

```
=MAX(IF(AND($A$1:$A$12=$D$1,B1:B12>PERCENTILE(B1:B12,0.2)),C1:C12))

```

The solution with both AND clauses should be 7

Can anyone help with this?

[![enter image description here](https://i.stack.imgur.com/aQ0KZ.png)](https://i.stack.imgur.com/aQ0KZ.png)

Answer: 
You could use a built-in function for this.

```
var_dump(ctype_space("\n"));

```

It takes a string of characters, but of course it will still work with a single character.
If you want to handle ALL possible white spaces including unicode:

```
echo preg_match('~^\p{Z}$~u',$char)?'white':'non-white';

```

This will cover these entities:

```
$chars=[
    "\u0009", // CHARACTER TABULATION (\t)
    "\u000A", // LINE FEED (LF) (\n)
    "\u000B", // LINE TABULATION
    "\u000C", // FORM FEED (FF)
    "\u000D", // CARRIAGE RETURN (CR) (\r)
    "\u0020", // SPACE ( )
    "\u0085", // NEXT LINE (NEL) 
    "\u00A0", // NO-BREAK SPACE
    "\u1680", // OGHAM SPACE MARK
    "\u180E", // MONGOLIAN VOWEL SEPARATOR
    "\u2000", // EN QUAD 
    "\u2001", // EM QUAD 
    "\u2002", // EN SPACE
    "\u2003", // EM SPACE
    "\u2004", // THREE-PER-EM SPACE
    "\u2005", // FOUR-PER-EM SPACE
    "\u2006", // SIX-PER-EM SPACE
    "\u2007", // FIGURE SPACE
    "\u2008", // PUNCTUATION SPACE
    "\u2009", // THIN SPACE
    "\u200A", // HAIR SPACE
    "\u2028", // LINE SEPARATOR
    "\u2029", // PARAGRAPH SEPARATOR
    "\u202F", // NARROW NO-BREAK SPACE
    "\u205F", // MEDIUM MATHEMATICAL SPACE
    "\u3000"  // IDEOGRAPHIC SPACE 
];

```