The if() function is Notion's way of saying "if this, then that." It's a conditional statement that allows you to return different values based on whether a condition is true or false.

Here's the basic structure:

The if() function is Notion's way of saying "if this, then that." It's a conditional statement that allows you to return different values based on whether a condition is true or false.

Here's the basic structure:

The if() function is Notion's way of saying "if this, then that." It's a conditional statement that allows you to return different values based on whether a condition is true or false.

Here's the basic structure:

The if() function is Notion's way of saying "if this, then that." It's a conditional statement that allows you to return different values based on whether a condition is true or false.

Here's the basic structure:

if(condition, value if true, value if false)
if(condition, value if true, value if false)
if(condition, value if true, value if false)
if(condition, value if true, value if false)

Let's break down the three parts of the if() function:

  1. Condition: This is your yes/no question. It needs to evaluate to either true or false.

  2. Value if true: What you want to return if the condition is met.

  3. Value if false: What you want to return if the condition isn't met.

For example, let's say you want to categorize tasks as "Done" if they're completed. Here's how you'd write that:

Let's break down the three parts of the if() function:

  1. Condition: This is your yes/no question. It needs to evaluate to either true or false.

  2. Value if true: What you want to return if the condition is met.

  3. Value if false: What you want to return if the condition isn't met.

For example, let's say you want to categorize tasks as "Done" if they're completed. Here's how you'd write that:

Let's break down the three parts of the if() function:

  1. Condition: This is your yes/no question. It needs to evaluate to either true or false.

  2. Value if true: What you want to return if the condition is met.

  3. Value if false: What you want to return if the condition isn't met.

For example, let's say you want to categorize tasks as "Done" if they're completed. Here's how you'd write that:

Let's break down the three parts of the if() function:

  1. Condition: This is your yes/no question. It needs to evaluate to either true or false.

  2. Value if true: What you want to return if the condition is met.

  3. Value if false: What you want to return if the condition isn't met.

For example, let's say you want to categorize tasks as "Done" if they're completed. Here's how you'd write that:

if(prop("Completed") == true, "Done", "Pending")
if(prop("Completed") == true, "Done", "Pending")
if(prop("Completed") == true, "Done", "Pending")
if(prop("Completed") == true, "Done", "Pending")

This formula checks if the task is completed. If it is, it returns "Done"; otherwise, it returns "Pending.”

This formula checks if the task is completed. If it is, it returns "Done"; otherwise, it returns "Pending.”

This formula checks if the task is completed. If it is, it returns "Done"; otherwise, it returns "Pending.”

This formula checks if the task is completed. If it is, it returns "Done"; otherwise, it returns "Pending.”

Notion Tip Icon

When working with checkbox properties, you can simplify your formulas. Instead of explicitly comparing to true, you can use the property directly in your condition. For instance:

if(prop("Completed"), "Done", "Pending")
Notion Tip Icon

When working with checkbox properties, you can simplify your formulas. Instead of explicitly comparing to true, you can use the property directly in your condition. For instance:

if(prop("Completed"), "Done", "Pending")
Notion Tip Icon

When working with checkbox properties, you can simplify your formulas. Instead of explicitly comparing to true, you can use the property directly in your condition. For instance:

if(prop("Completed"), "Done", "Pending")
Notion Tip Icon

When working with checkbox properties, you can simplify your formulas. Instead of explicitly comparing to true, you can use the property directly in your condition. For instance:

if(prop("Completed"), "Done", "Pending")

Nested if() Statements

Sometimes, you need to handle more than just two outcomes. In such cases, you can create more complex logic by combining multiple if() functions. This allows you to evaluate several conditions and return different results based on each one.

Let's expand our task categorization:

Nested if() Statements

Sometimes, you need to handle more than just two outcomes. In such cases, you can create more complex logic by combining multiple if() functions. This allows you to evaluate several conditions and return different results based on each one.

Let's expand our task categorization:

Nested if() Statements

Sometimes, you need to handle more than just two outcomes. In such cases, you can create more complex logic by combining multiple if() functions. This allows you to evaluate several conditions and return different results based on each one.

Let's expand our task categorization:

Nested if() Statements

Sometimes, you need to handle more than just two outcomes. In such cases, you can create more complex logic by combining multiple if() functions. This allows you to evaluate several conditions and return different results based on each one.

Let's expand our task categorization:

if(prop("Completed"), "Done",
  if(dateBetween(prop("Due Date"), now(), "days") <= 3, "Urgent",
    if(dateBetween(prop("Due Date"), now(), "days") <= 7, "This Week", "Upcoming")
  )
)
if(prop("Completed"), "Done",
  if(dateBetween(prop("Due Date"), now(), "days") <= 3, "Urgent",
    if(dateBetween(prop("Due Date"), now(), "days") <= 7, "This Week", "Upcoming")
  )
)
if(prop("Completed"), "Done",
  if(dateBetween(prop("Due Date"), now(), "days") <= 3, "Urgent",
    if(dateBetween(prop("Due Date"), now(), "days") <= 7, "This Week", "Upcoming")
  )
)
if(prop("Completed"), "Done",
  if(dateBetween(prop("Due Date"), now(), "days") <= 3, "Urgent",
    if(dateBetween(prop("Due Date"), now(), "days") <= 7, "This Week", "Upcoming")
  )
)

In this formula, first check if the task is completed. If not, it checks if it's due within 3 days (Urgent), then within 7 days (This Week), and if neither, it's labeled as Upcoming.

In this formula, first check if the task is completed. If not, it checks if it's due within 3 days (Urgent), then within 7 days (This Week), and if neither, it's labeled as Upcoming.

In this formula, first check if the task is completed. If not, it checks if it's due within 3 days (Urgent), then within 7 days (This Week), and if neither, it's labeled as Upcoming.

In this formula, first check if the task is completed. If not, it checks if it's due within 3 days (Urgent), then within 7 days (This Week), and if neither, it's labeled as Upcoming.

Notion Note Icon

Make sure each if() statement is properly closed with a parenthesis.

Notion Note Icon

Make sure each if() statement is properly closed with a parenthesis.

Notion Note Icon

Make sure each if() statement is properly closed with a parenthesis.

Notion Note Icon

Make sure each if() statement is properly closed with a parenthesis.

In this case, our formula grew and became more complex. As formulas become intricate, it's important to keep them readable and maintainable, so we can easily understand our previous work when revisiting the formula.

Here are some strategies I typically use to manage complexity:

In this case, our formula grew and became more complex. As formulas become intricate, it's important to keep them readable and maintainable, so we can easily understand our previous work when revisiting the formula.

Here are some strategies I typically use to manage complexity:

In this case, our formula grew and became more complex. As formulas become intricate, it's important to keep them readable and maintainable, so we can easily understand our previous work when revisiting the formula.

Here are some strategies I typically use to manage complexity:

In this case, our formula grew and became more complex. As formulas become intricate, it's important to keep them readable and maintainable, so we can easily understand our previous work when revisiting the formula.

Here are some strategies I typically use to manage complexity:

    1. Use line breaks and indentation: Structure your formula visually to make it easier to understand at a glance. For example:

    1. Use line breaks and indentation: Structure your formula visually to make it easier to understand at a glance. For example:

    1. Use line breaks and indentation: Structure your formula visually to make it easier to understand at a glance. For example:

    1. Use line breaks and indentation: Structure your formula visually to make it easier to understand at a glance. For example:

    if(
      prop("Completed"), "Done",
      if(
        dateBetween(prop("Due Date"), now(), "days") <= 3, "Urgent",
        if(
          dateBetween(prop("Due Date"), now(), "days") <= 7, "This Week",
          "Upcoming"
        )
      )
    )
    if(
      prop("Completed"), "Done",
      if(
        dateBetween(prop("Due Date"), now(), "days") <= 3, "Urgent",
        if(
          dateBetween(prop("Due Date"), now(), "days") <= 7, "This Week",
          "Upcoming"
        )
      )
    )
    if(
      prop("Completed"), "Done",
      if(
        dateBetween(prop("Due Date"), now(), "days") <= 3, "Urgent",
        if(
          dateBetween(prop("Due Date"), now(), "days") <= 7, "This Week",
          "Upcoming"
        )
      )
    )
    if(
      prop("Completed"), "Done",
      if(
        dateBetween(prop("Due Date"), now(), "days") <= 3, "Urgent",
        if(
          dateBetween(prop("Due Date"), now(), "days") <= 7, "This Week",
          "Upcoming"
        )
      )
    )
    1. Break complex logic into separate properties: Instead of one massive formula, create intermediate properties that handle part of the logic. This makes each formula more focused and easier to understand.

    1. Break complex logic into separate properties: Instead of one massive formula, create intermediate properties that handle part of the logic. This makes each formula more focused and easier to understand.

    1. Break complex logic into separate properties: Instead of one massive formula, create intermediate properties that handle part of the logic. This makes each formula more focused and easier to understand.

    1. Break complex logic into separate properties: Instead of one massive formula, create intermediate properties that handle part of the logic. This makes each formula more focused and easier to understand.

    1. Use the ifs() function. For multiple conditions, ifs() can be more readable than nested if() statements. Here's how you could rewrite the above formula:

    1. Use the ifs() function. For multiple conditions, ifs() can be more readable than nested if() statements. Here's how you could rewrite the above formula:

    1. Use the ifs() function. For multiple conditions, ifs() can be more readable than nested if() statements. Here's how you could rewrite the above formula:

    1. Use the ifs() function. For multiple conditions, ifs() can be more readable than nested if() statements. Here's how you could rewrite the above formula:

    ifs(
      prop("Completed"), "Done",
      dateBetween(prop("Due Date"), now(), "days") <= 3, "Urgent",
      dateBetween(prop("Due Date"), now(), "days") <= 7, "This Week",
      true, "Upcoming"
    )
    ifs(
      prop("Completed"), "Done",
      dateBetween(prop("Due Date"), now(), "days") <= 3, "Urgent",
      dateBetween(prop("Due Date"), now(), "days") <= 7, "This Week",
      true, "Upcoming"
    )
    ifs(
      prop("Completed"), "Done",
      dateBetween(prop("Due Date"), now(), "days") <= 3, "Urgent",
      dateBetween(prop("Due Date"), now(), "days") <= 7, "This Week",
      true, "Upcoming"
    )
    ifs(
      prop("Completed"), "Done",
      dateBetween(prop("Due Date"), now(), "days") <= 3, "Urgent",
      dateBetween(prop("Due Date"), now(), "days") <= 7, "This Week",
      true, "Upcoming"
    )

    The ifs() function takes pairs of conditions and results, evaluating each condition in order until one is true. The last pair should have true as the condition to act as a default case.

    The ifs() function takes pairs of conditions and results, evaluating each condition in order until one is true. The last pair should have true as the condition to act as a default case.

    The ifs() function takes pairs of conditions and results, evaluating each condition in order until one is true. The last pair should have true as the condition to act as a default case.

    The ifs() function takes pairs of conditions and results, evaluating each condition in order until one is true. The last pair should have true as the condition to act as a default case.

Practical Applications

Now that you've got the basics down, let's look at some scenarios where if() can save you time and make your databases smarter:

Practical Applications

Now that you've got the basics down, let's look at some scenarios where if() can save you time and make your databases smarter:

Practical Applications

Now that you've got the basics down, let's look at some scenarios where if() can save you time and make your databases smarter:

Practical Applications

Now that you've got the basics down, let's look at some scenarios where if() can save you time and make your databases smarter:

Project Status Tracking

Use if() to automatically update project statuses based on progress:

Project Status Tracking

Use if() to automatically update project statuses based on progress:

Project Status Tracking

Use if() to automatically update project statuses based on progress:

Project Status Tracking

Use if() to automatically update project statuses based on progress:

if(prop("Progress") == 100, "Complete",
  if(prop("Progress") > 0, "In Progress", "Not Started")
)
if(prop("Progress") == 100, "Complete",
  if(prop("Progress") > 0, "In Progress", "Not Started")
)
if(prop("Progress") == 100, "Complete",
  if(prop("Progress") > 0, "In Progress", "Not Started")
)
if(prop("Progress") == 100, "Complete",
  if(prop("Progress") > 0, "In Progress", "Not Started")
)

This formula checks if the project progress is 100%. If it is, it returns "Complete". If not, it checks if the progress is greater than 0. If it is, it returns "In Progress"; otherwise, it returns "Not Started". Here's a breakdown:

  • If the progress is 100%, the project is complete.

  • If the progress is greater than 0 but not 100%, the project is in progress.

  • If the progress is 0, the project has not started.

This formula checks if the project progress is 100%. If it is, it returns "Complete". If not, it checks if the progress is greater than 0. If it is, it returns "In Progress"; otherwise, it returns "Not Started". Here's a breakdown:

  • If the progress is 100%, the project is complete.

  • If the progress is greater than 0 but not 100%, the project is in progress.

  • If the progress is 0, the project has not started.

This formula checks if the project progress is 100%. If it is, it returns "Complete". If not, it checks if the progress is greater than 0. If it is, it returns "In Progress"; otherwise, it returns "Not Started". Here's a breakdown:

  • If the progress is 100%, the project is complete.

  • If the progress is greater than 0 but not 100%, the project is in progress.

  • If the progress is 0, the project has not started.

This formula checks if the project progress is 100%. If it is, it returns "Complete". If not, it checks if the progress is greater than 0. If it is, it returns "In Progress"; otherwise, it returns "Not Started". Here's a breakdown:

  • If the progress is 100%, the project is complete.

  • If the progress is greater than 0 but not 100%, the project is in progress.

  • If the progress is 0, the project has not started.

Notion Tip Icon

For simple conditions, you can use the ternary operator (? :). This achieves the same result but can be more concise for simple conditions. Here's how you could rewrite the "Not Started" condition:

if(prop("Progress") > 0,
  prop("Progress") == 100 ? "Complete": "In Progress"),
  "Not Started")
Notion Tip Icon

For simple conditions, you can use the ternary operator (? :). This achieves the same result but can be more concise for simple conditions. Here's how you could rewrite the "Not Started" condition:

if(prop("Progress") > 0,
  prop("Progress") == 100 ? "Complete": "In Progress"),
  "Not Started")
Notion Tip Icon

For simple conditions, you can use the ternary operator (? :). This achieves the same result but can be more concise for simple conditions. Here's how you could rewrite the "Not Started" condition:

if(prop("Progress") > 0,
  prop("Progress") == 100 ? "Complete": "In Progress"),
  "Not Started")
Notion Tip Icon

For simple conditions, you can use the ternary operator (? :). This achieves the same result but can be more concise for simple conditions. Here's how you could rewrite the "Not Started" condition:

if(prop("Progress") > 0,
  prop("Progress") == 100 ? "Complete": "In Progress"),
  "Not Started")

Dynamic Pricing

Adjust prices based on quantity ordered:

Dynamic Pricing

Adjust prices based on quantity ordered:

Dynamic Pricing

Adjust prices based on quantity ordered:

Dynamic Pricing

Adjust prices based on quantity ordered:

if(prop("Quantity") >= 100, prop("Base Price") * 0.8,
  if(prop("Quantity") >= 50, prop("Base Price") * 0.9, prop("Base Price"))
)
if(prop("Quantity") >= 100, prop("Base Price") * 0.8,
  if(prop("Quantity") >= 50, prop("Base Price") * 0.9, prop("Base Price"))
)
if(prop("Quantity") >= 100, prop("Base Price") * 0.8,
  if(prop("Quantity") >= 50, prop("Base Price") * 0.9, prop("Base Price"))
)
if(prop("Quantity") >= 100, prop("Base Price") * 0.8,
  if(prop("Quantity") >= 50, prop("Base Price") * 0.9, prop("Base Price"))
)

First, it checks if the quantity ordered is 100 or more. If true, it applies a 20% discount (multiplies the base price by 0.8)

  1. If the first condition is false, it then checks if the quantity is 50 or more. If true, it applies a 10% discount (multiplies the base price by 0.9)

  2. If both conditions are false (i.e., quantity is less than 50), it returns the original base price without any discount

First, it checks if the quantity ordered is 100 or more. If true, it applies a 20% discount (multiplies the base price by 0.8)

  1. If the first condition is false, it then checks if the quantity is 50 or more. If true, it applies a 10% discount (multiplies the base price by 0.9)

  2. If both conditions are false (i.e., quantity is less than 50), it returns the original base price without any discount

First, it checks if the quantity ordered is 100 or more. If true, it applies a 20% discount (multiplies the base price by 0.8)

  1. If the first condition is false, it then checks if the quantity is 50 or more. If true, it applies a 10% discount (multiplies the base price by 0.9)

  2. If both conditions are false (i.e., quantity is less than 50), it returns the original base price without any discount

First, it checks if the quantity ordered is 100 or more. If true, it applies a 20% discount (multiplies the base price by 0.8)

  1. If the first condition is false, it then checks if the quantity is 50 or more. If true, it applies a 10% discount (multiplies the base price by 0.9)

  2. If both conditions are false (i.e., quantity is less than 50), it returns the original base price without any discount

Performance Ratings

Assign ratings based on numerical scores:

Performance Ratings

Assign ratings based on numerical scores:

Performance Ratings

Assign ratings based on numerical scores:

Performance Ratings

Assign ratings based on numerical scores:

if(prop("Score") >= 90, "Excellent",
  if(prop("Score") >= 80, "Good",
    if(prop("Score") >= 70, "Average", "Needs Improvement")
  )
)
if(prop("Score") >= 90, "Excellent",
  if(prop("Score") >= 80, "Good",
    if(prop("Score") >= 70, "Average", "Needs Improvement")
  )
)
if(prop("Score") >= 90, "Excellent",
  if(prop("Score") >= 80, "Good",
    if(prop("Score") >= 70, "Average", "Needs Improvement")
  )
)
if(prop("Score") >= 90, "Excellent",
  if(prop("Score") >= 80, "Good",
    if(prop("Score") >= 70, "Average", "Needs Improvement")
  )
)

In our last example, this formula checks the score and assigns a rating accordingly:

  • If the score is 90 or higher, the rating is "Excellent".

  • If the score is 80 or higher but less than 90, the rating is "Good".

  • If the score is 70 or higher but less than 80, the rating is "Average".

  • If the score is less than 70, the rating is "Needs Improvement".

In our last example, this formula checks the score and assigns a rating accordingly:

  • If the score is 90 or higher, the rating is "Excellent".

  • If the score is 80 or higher but less than 90, the rating is "Good".

  • If the score is 70 or higher but less than 80, the rating is "Average".

  • If the score is less than 70, the rating is "Needs Improvement".

In our last example, this formula checks the score and assigns a rating accordingly:

  • If the score is 90 or higher, the rating is "Excellent".

  • If the score is 80 or higher but less than 90, the rating is "Good".

  • If the score is 70 or higher but less than 80, the rating is "Average".

  • If the score is less than 70, the rating is "Needs Improvement".

In our last example, this formula checks the score and assigns a rating accordingly:

  • If the score is 90 or higher, the rating is "Excellent".

  • If the score is 80 or higher but less than 90, the rating is "Good".

  • If the score is 70 or higher but less than 80, the rating is "Average".

  • If the score is less than 70, the rating is "Needs Improvement".

In addition to assigning ratings, we can use the if() function to provide default values for empty fields. Let's add an "Display Name" column and ensure it always has a value.

In addition to assigning ratings, we can use the if() function to provide default values for empty fields. Let's add an "Display Name" column and ensure it always has a value.

In addition to assigning ratings, we can use the if() function to provide default values for empty fields. Let's add an "Display Name" column and ensure it always has a value.

In addition to assigning ratings, we can use the if() function to provide default values for empty fields. Let's add an "Display Name" column and ensure it always has a value.

if(empty(prop("Employee Name")), "Unnamed Employee", prop("Employee Name"))
if(empty(prop("Employee Name")), "Unnamed Employee", prop("Employee Name"))
if(empty(prop("Employee Name")), "Unnamed Employee", prop("Employee Name"))
if(empty(prop("Employee Name")), "Unnamed Employee", prop("Employee Name"))

This formula checks if the "Employee Name" field is empty. If it is, it returns "Unnamed Employee"; otherwise, it returns the actual employee name.

This formula checks if the "Employee Name" field is empty. If it is, it returns "Unnamed Employee"; otherwise, it returns the actual employee name.

This formula checks if the "Employee Name" field is empty. If it is, it returns "Unnamed Employee"; otherwise, it returns the actual employee name.

This formula checks if the "Employee Name" field is empty. If it is, it returns "Unnamed Employee"; otherwise, it returns the actual employee name.