Examples
IF(TRUE, "Yes!", "No!")
: Yes!
IF(FALSE, "Yes!", "No!")
: No!
IF((1 > 0), "Yes!", "No!")
: Yes!
IF((1 < 0), "Yes!", "No!")
: No!
IF(ISBLANK(""), "Yes!", "No!")
: 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 MIN(LIST(0, [Count]))
. See also: LIST(), MIN().
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, the Name column value is returned unchanged. See also: UPPER(), USERSETTINGS().
IF(ISNOTBLANK([Phone Number]), [Phone Number], "(no phone)")
: If the Phone Number column value isn't blank, the column value itself is returned; otherwise, the text, (no phone), is returned.
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"
)
TODAY()
gives today's date.YEAR(...)
gives the year of the given date."2/28/" & ...
constructs a Text value in MM/DD/YYYY-format date for February 28 of this year.DATE(...)
declares the constructed Text value a Date value.DATE(...) + 1
adds one day to the given date.MONTH(...)
gives the month number of the computed date, 1 to 12, where 1 is January and 12 is December.((...) = 2)
asks whether the month number is 2 (February).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."
)
TODAY()
gives today's date.WEEKDAY(...)
gives the weekday number of the given date, 1 to 7, where 1 is Sunday and 7 is Saturday.LIST(1, 7)
constructs a list of two numbers: 1 and 7.IN(..., ...)
asks whether the computed weekday number is present in the constructed list.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( is-true? , then-do-this , else-do-this )
Arguments
- is-true? (Yes/No): An expression that returns TRUE or FALSE.
- then-do-this : An expression to be evaluated only if the is-true? expression evaluates as TRUE.
- else-do-this : An expression to be evaluated only if the is-true? expression evaluates as FALSE.
Both then-do-this and else-do-this should produce results of comparable types (e.g., both textual, or both numeric). The results may both be single values or lists.
Return Value
If is-true? evaluates as TRUE, the result of evaluating then-do-this is returned; otherwise, the result of evaluating else-do-this is returned.