Home  >  Article  >  Detailed explanation of the usage of conditional function if

Detailed explanation of the usage of conditional function if

hzc
hzcOriginal
2020-07-04 15:25:5810856browse

IF function generally refers to the conditional function in programming or Excel and other software. It determines its "true" [TRUE] and "false" [FALSE] according to the specified conditions, and calculates the true and false values ​​​​based on the logic. , thereby returning the corresponding content. You can use the function IF to perform conditional testing on values ​​and formulas.

Detailed explanation of the usage of conditional function if

IF function generally refers to the conditional function in programming or Excel and other software, which determines its "true" (TRUE) or "false" based on specified conditions. ” (FALSE), based on the true and false values ​​calculated logically, thereby returning the corresponding content. You can use the function IF to perform conditional testing on values ​​and formulas.

Syntax

IF(logical_test,value_if_true,value_if_false)

Function

IF function is a conditional judgment function: if the specified condition If the condition evaluates to TRUE, the IF function will return a certain value; if the condition evaluates to FALSE, it will return another value.

For example, IF (test condition, result 1, result 2), that is, if the "test condition" is met, "result 1" is displayed, and if the "test condition" is not met, "result 2" is displayed.

Parameters

(1) Logical_test represents any value or expression that evaluates to TRUE or FALSE. [2]

For example, A10=100 is a logical expression. If the value in cell A10 is equal to 100, the expression is TRUE, otherwise it is FALSE. This parameter can use any comparison operator (= (equal to), > (greater than), >= (greater than or equal to), <= (less than or equal to, etc. operators)).

(2) Value_if_true represents the value returned when logical_test is TRUE.

For example, if this parameter is the text string "Within budget" and the logical_test parameter value is TRUE, the IF function will display the text "Within budget". If logical_test is TRUE and value_if_true is empty, this parameter returns 0. If TRUE is to be displayed, use the logical value TRUE for this parameter. value_if_true can also be other formulas.

(3) Value_if_false represents the value returned when logical_test is FALSE.

For example, if this parameter is the text string "Over budget" and the logical_test parameter value is FALSE, the IF function will display the text "Over budget". If logical_test is FALSE and value_if_false is omitted (that is, there is no comma after value_if_true), the logical value FALSE is returned. If logical_test is FALSE and value_if_false is empty (that is, value_if_true is followed by a comma and immediately follows the closing parenthesis), this parameter returns 0 (zero). VALUE_if_false can also be other formulas.

Explanation

In Excel2003, the function IF can be nested seven levels, and in Excel2007, it can be nested 64 levels. Complex detection conditions can be constructed using the value_if_false and value_if_true parameters.

After calculating the parameters value_if_true and value_if_false, the function IF returns the return value after the corresponding statement is executed.

If the argument to function IF contains an array ( Used to create a single formula that produces multiple results or operates on a set of arguments arranged in rows and columns. Array ranges share a formula; array constants are a set of constants used as parameters), each element in the array will be evaluated when the IF statement is executed.

Excel tables also provide some other functions that can analyze data based on conditions. For example, if you want to count the number of times a text string or number occurs in a range of cells, you can use the COUNTIF worksheet function. If you want to sum a text string or number in a range of cells, you can use the SUMIF worksheet function. Learn about calculating values ​​based on conditions.

The above is the detailed content of Detailed explanation of the usage of conditional function if. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn