Notification

The AppSheet Help Center documentation can now be viewed in Japanese - AppSheet ヘルプセンターのドキュメントが日本語で表示できるようになりました。. Learn more

IF()

Either/or conditional evaluation

Returns the results of an either/or conditional evaluation. If the initial argument evaluates as TRUE, returns the result of evaluating the second argument; otherwise, returns the result of evaluating the third argument.

Sample usage

IF(TRUE, "Yes!", "No!") returns Yes!

IF(FALSE, "Yes!", "No!") returns No!

IF((1 > 0), "Yes!", "No!") returns Yes!

IF((1 < 0), "Yes!", "No!") returns No!

IF(ISBLANK(""), "Yes!", "No!") returns Yes! See also: ISBLANK().

IF(NOT(ISBLANK("")), "Yes!", "No!") : No! Equivalent to IF(ISNOTBLANK(""), "Yes!", "No!"). See also: ISNOTBLANK(), NOT().

IF(([Count] < 0), 0, [Count])  returns 0 if the Count column value is less than zero, or the value itself if zero or greater. Equivalent to MAX(LIST(0, [Count])). See also: LIST(),  MAX().

IF(([Date] = TODAY()), TRUE, FALSE) : Returns TRUE if the Date column value matches today's date; otherwise, returns FALSE. Equivalent to ([Date] = TODAY()). See also: TODAY().

IF(USERSETTINGS("Names in uppercase?"), UPPER([Name]), [Name]) returns the Name column in all uppercase letters if the value of the Names in uppercase? user setting is TRUE; otherwise,  returns the Name column value unchanged. See also: UPPER(), USERSETTINGS().

IF(ISNOTBLANK([Phone Number]), [Phone Number], "(no phone)") returns the column value if the Phone Number column value isn't blank; otherwise, returns the text (no phone).

IF(ISNOTBLANK([Customer].[Discount Rate]), ([Price] * [Customer].[Discount Rate]), [Price]) : If the customer has a discount, the discounted price is returned; otherwise, the original price is returned.

Leap year?

IF(
  (
    MONTH(
      DATE(
        "2/28/"
        & YEAR(TODAY())
      )
      + 1
    )
    = 2
  ),
  "leap year",
  "not leap year"
)
  1. TODAY() gives today's date.
  2. YEAR(...) gives the year of the given date.
  3. "2/28/" & ... constructs a Text value in MM/DD/YYYY-format date for February 28 of this year.
  4. DATE(...) declares the constructed Text value a Date value.
  5. DATE(...) + 1 adds one day to the given date.
  6. MONTH(...) gives the month number of the computed date, 1 to 12, where 1 is January and 12 is December.
  7. ((...) = 2) asks whether the month number is 2 (February).
  8. IF(..., "leap year", "not leap year") gives leap year if the day after February 28 of this year is in February, or not leap year if not.

See also: DATE(), MONTH(), TODAY(), YEAR().

Weekday or weekend?

IF(
  IN(
    WEEKDAY(TODAY()),
    LIST(1, 7)
  ),
  "It's the weekend!",
  "It's a weekday."
)
  1. TODAY() gives today's date.
  2. WEEKDAY(...) gives the weekday number of the given date, 1 to 7, where 1 is Sunday and 7 is Saturday.
  3. LIST(1, 7) constructs a list of two numbers: 1 and 7.
  4. IN(..., ...) asks whether the computed weekday number is present in the constructed list.
  5. IF(..., "It's the weekend!", "It's a weekday.") gives It's the weekend! if the the weekday number is 1 or 7, or It's a weekday. otherwise.

See also: IN(), LIST(), TODAY(), WEEKDAY().

Syntax

IF(logical-expressionvalue-if-true, value-if-false)

  • logical-expression -  A Yes/No expression that evaluates to TRUE or FALSE.
  • value-if-true - An expression to be evaluated only if the logical-expression evaluates as TRUE.
  • value-if-false - An expression to be evaluated only if the logical-expression evaluates as FALSE.

Both value-if-true and value-if-false should produce results of comparable types (for example, both textual, or both numeric). The results may both be single values or lists.

See also

IFS()

SWITCH()

Was this helpful?

How can we improve it?

Need more help?

Try these next steps:

true
Search
Clear search
Close search
Main menu
8855258913503670754
true
Search Help Center
true
true
true
false
false