What are Calculations?
Calculations are mathematical and logical expressions that run on the data in your RLD Project to create new fields.
Some examples are:
- Adding the numbers on a form together to get a total
- Checking if a user entered a specific number into the form
- Getting the time between 2 buttons clicks
- Counting the number of times a button was clicked
- Getting the average of a number entered into a form by many different users
- Getting the percent of times users entered a specific value into your form
Imagine you created a form to track revenue, number of items produced, and money spent every day.
Using calculations would allow you to determine:
- Average revenue per day
- Percent of time revenue is above 5000
- Subtract money spent from revenue to find profit every day
- Divide items produced by money spent to find the cost of goods sold
- And much more!
In the rest of this section we will cover how to make a few basic calculations.
Creating Basic Calculations
All the calculations will be based off of the getting started section Creating a Data Input App. If you are unsure what to do, go to that section first.
Number Calculation
Our first calculation will be really simple: We will take the number put into the slider and divide it by 100.
- To get started click + Add New Calculation
- Click where is says "Calc Name" and enter in "First Calculation"
- On the left sidebar under find Revenue, click and drag it into the white box next to our calculation name.
- On the right sidebar under find the divide symbol that looks like this . Click and drag it to the right of Revenue
- On the right sidebar under find Number: that looks like this . Click and drag it to the right of our divide.
- Click on the number inside your operation and change it to 100, then click enter to lock it in.
Logic and Text Calculation
This calculation will check if the user entered "January" into our form.
- Click + Add New Calculation
- Name this calculation "January Entered"
- On the left sidebar under find Month, click and drag it into the white box next to our calculation name.
- On the right sidebar under find the == symbol that looks like this . Click and drag it to the right of Month
- On the right sidebar under find Text: that looks like this . Click and drag it to the right of our ==.
- Click on the number inside your operation and change it to "January", then click enter to lock it in. **NOTE: the text constant is cas sensitive, so make sure you type exactly "January".
Button Calculation
This calculations will count the number of times the submit button is pressed. We know that since this button submits our data it should only ever be 1.
- Click + Add New Calculation
- Name this calculation "Number of Submits"
- On the right sidebar under find the COunt() function that looks like this . Click and drag it into the operations box.
- On the left sidebar under find Submit Button, click and drag it into the parentheses of the Count() function.
Basics Group By Calculation
What is a Group By
This section will cover doing some basic calculations using a concept known as Group By.
Group By Allows you to do things like:
- Average per month
- Median Score per team
- Percent of time a goal is met per year
- Total per team
Anytime you see the word per in a description of a calculation it means it will need to use Group By.
Creating a Basic Group By Calculation
Our New Calculation
Our first group by calculation will be called "Average Revenue Per Month". It will give us the average revenue per unique month entered into the text input. So if someone entered the following data into our form:
- Revenue: 100, Month: January
- Revenue: 0, Month: January
- Revenue: 60, Month: February
- Revenue: 100, Month: February
Our calculation would give us back:
- Month: January, Average Revenue Per Month: 50
- Month: February, Average Revenue Per Month: 80
Creating Our New Calculation
To create a Group By calculation we need to create a new tab.
- Go to the top where it says "tab-1" and click the "+" button next to it.
- Enter in a name for the tab: "Group By Tab"
- On the left sidebar under find Month, click and drag it into the box that says GROUP BY
- Click + Add New Calculation
- Click where is says "Calc Name" and enter in "Average Per Text"
- On the right sidebar under find the Average() function that looks like this . Click and drag it into the operations box.
- On the left sidebar under find Revenue, click and drag it into the parentheses of the Average() function.