Equations
Transcript Summary
Introduction
What's up, databasers? Sam here, and in this video, I'm going to talk all about equations. Equations allow you to use more complex formula functions to be run on your values. This may sound complex, but it'll make sense soon.
In this video, we’ll cover:
- What are equations?
- Types of equations in your database.
- How can you use them in your app?
What Are Equations?
Equations work within the same table and contain many different equation options, including various functions and formulas. They are more complex than basic number, date, and text fields but can be more powerful.
Example Use Case
Let's jump right into an example app that has equation fields. Here, we have a list of customers and their jobs. For each job, we have job prices, and we’ll be using equations to add specific rules, like adding fees to certain jobs.
Example 1: Adding a Small Job Fee
- Scenario: If a job price is below $1,000, we want to add a $50 small job fee.
- How It Works: Using an IF formula, if the job price is less than $1,000, we add an extra $50 fee. For example, if a job is priced at $200, we add a $50 processing fee.
Example 2: Calculating Total Job Time in Days
- Scenario: We want to calculate the time difference between the start and end dates of a job.
- How It Works: This equation calculates the total number of days from the start date to the end date. If the job is still ongoing (no end date), it calculates the days up to the current date.
Example 3: Earned Per Day
- Scenario: We want to see how much was earned per day for each job.
- How It Works: We take the job price and divide it by the total job time in days. This gives us an average daily earning rate for each job.
Example 4: Using Text Functions
- Scenario: We want to convert job categories to all uppercase letters.
- How It Works: A text equation is used to take the job category and transform it to uppercase, useful for formatting purposes like invoicing.
How to Create Equation Fields
Step 1: Creating a Text Equation
We’ll start by creating a text equation for job categories:
- Select the
equation
field type. - Add a field like "Job Category."
- Use the
UPPER
text function to convert the text to uppercase. - Validate the equation and set the output type to
text
. - Save and check your records to see the job categories now in uppercase.
Step 2: Creating a Number Equation for a Small Job Fee
Next, we’ll create a number equation to add a $50 small job fee if the job is under $1,000:
- Create an equation field named "Plus Small Job Fee."
- Use the IF function: If the job price is less than $1,000, add $50. Otherwise, do nothing.
- Validate the equation, set the output type to
number
, and format as needed (e.g., decimal places). - Save and check your records to see the fee added for jobs under $1,000.
Step 3: Creating a Date Equation for Total Job Time
Now, we’ll create a date equation to calculate the total job time:
- Create a field named "Total Job Time."
- Use an IF function to check if the job status is "complete." If true, calculate the difference between the start and end date. If false, calculate the difference between the start date and the current date.
- Validate the equation and set the output type to
number
for days. - Save and check your records to see the total job time in days.
Step 4: Creating an Earned Per Day Equation
Lastly, we’ll calculate the earnings per day:
- Create an equation field named "Earned Per Day."
- Use the job price divided by the total job time to calculate the daily earnings.
- Validate the equation, set the output type to
number
, and save. - Check the records to see how much is earned per day for each job.
Conclusion
That wraps up this video. I hope you found it helpful and are now more knowledgeable about using equations in your app. Thanks for watching!
We'd love to hear your feedback.