Excel functions
Logical functions
Logical functions let a formula choose. IF and IFS return different results depending on a test, AND, OR, NOT and XOR combine tests, IFERROR catches mistakes, and the newer LET, LAMBDA, MAP, REDUCE and SCAN turn formulas into small reusable programs.
Start with these
ANDReturns TRUE only when every condition you give it is TRUE, and FALSE as soon as any one of them is FALSE.IFTests a condition and returns one value when it is TRUE and another when it is FALSE. The basis of almost every decision formula in Excel.IFERRORReturns a value you choose when a formula results in an error, and the formula's normal result otherwise. Ideal for tidying #DIV/0! and #N/A.IFSChecks several conditions in order and returns the value for the first one that is TRUE. A cleaner alternative to nested IF formulas.LAMBDACreates your own reusable function from an Excel formula, with named parameters. Save it in Name Manager to call it like a built-in function.LETGives names to values or calculations inside one formula, so long formulas are easier to read and repeated parts are calculated only once.NOTReverses a logical value: TRUE becomes FALSE and FALSE becomes TRUE. Useful for "is not" conditions and excluding cases.ORReturns TRUE if at least one of the conditions is TRUE, and FALSE only when all of them are FALSE.SWITCHCompares one value against a list of options and returns the result paired with the first exact match, with an optional default.
All 19 logical functions
- ANDReturns TRUE only when every condition you give it is TRUE, and FALSE as soon as any one of them is FALSE.
- BYCOLRuns a LAMBDA on each column of a range and returns one result per column, for example a total or average for every month.
- BYROWRuns a LAMBDA on each row of a range and returns one result per row, such as a total or a status for every employee.
- FALSEReturns the logical value FALSE. Mostly kept for compatibility, since you can simply type FALSE into a cell or formula.
- IFTests a condition and returns one value when it is TRUE and another when it is FALSE. The basis of almost every decision formula in Excel.
- IFERRORReturns a value you choose when a formula results in an error, and the formula's normal result otherwise. Ideal for tidying #DIV/0! and #N/A.
- IFNAReturns a value you specify when a formula gives #N/A, and the formula's result otherwise. Catches only #N/A, so other errors stay visible.
- IFSChecks several conditions in order and returns the value for the first one that is TRUE. A cleaner alternative to nested IF formulas.
- LAMBDACreates your own reusable function from an Excel formula, with named parameters. Save it in Name Manager to call it like a built-in function.
- LETGives names to values or calculations inside one formula, so long formulas are easier to read and repeated parts are calculated only once.
- MAKEARRAYBuilds a grid of a given number of rows and columns, filling each cell with the result of a LAMBDA that receives the row and column number.
- MAPApplies a LAMBDA to every value in one or more arrays and returns an array of results of the same size.
- NOTReverses a logical value: TRUE becomes FALSE and FALSE becomes TRUE. Useful for "is not" conditions and excluding cases.
- ORReturns TRUE if at least one of the conditions is TRUE, and FALSE only when all of them are FALSE.
- REDUCERuns through an array with a LAMBDA, carrying an accumulator from step to step, and returns only the final accumulated value.
- SCANRuns a LAMBDA through an array with an accumulator and returns every intermediate result, e.g. a running total or running balance.
- SWITCHCompares one value against a list of options and returns the result paired with the first exact match, with an optional default.
- TRUEReturns the logical value TRUE. You can also just type TRUE; the function exists mainly for compatibility with other spreadsheet programs.
- XORExclusive OR: returns TRUE when an odd number of the conditions are TRUE. With two conditions it means "exactly one, not both".