Skip to content
Dropfile

IF Function

Tests a condition and returns one value if TRUE and another if FALSE. The most fundamental decision-making function in spreadsheets.

ExcelGoogle Sheets

语法

IF(logical_test, value_if_true, [value_if_false])

参数

参数名说明
logical_testThe condition to evaluate (e.g., A1>10).
value_if_trueThe value returned when the condition is TRUE.
value_if_false(可选)The value returned when the condition is FALSE.

示例

Pass/Fail based on a score

=IF(A1>=60, "Pass", "Fail")

结果: Pass (if A1 is 75)

Nested IF for letter grades

=IF(A1>=90, "A", IF(A1>=80, "B", IF(A1>=70, "C", "F")))

结果: B (if A1 is 85)

Calculate bonus if sales target met

=IF(B2>=10000, B2*0.1, 0)

结果: 1500 (if B2 is 15000)

技巧与最佳实践

相关公式

需要其他公式?

用自然语言描述您的需求,AI 将为您生成公式。

试试公式生成器