You can use basic operators like +, -, x, and / by typing them out on the keyboard. You can easily build simple cost and savings calculators with these basic operators. You can also use advanced operators like ^ and log. Simply type them out on your keyboard.
To understand how to design more complicated formulas, please go through the sections below.
To use conditional expressions, you need to use a formula of type ((x) ? y : z). Let's use it in an example for better understanding:
Say, we are trying to access the risk of you hitting your head on the ceiling and it depends on your height. So you will ask a question "What is your height?" and on the basis of the answer assign a risk value.
The expression will take the form: If my height is < 4.5 feet then my risk of hitting my head on the roof is 50%, else it is 90%. Here's how you can write this expression in the formula builder:
((Q1 < 4.5)? 50 : 90)
*Here, "?" becomes the expression for "then", and ":" becomes the expression for "else".
This was a simple example but it can be more complicated in a real situation. Say, there was another question that asked if you have good eye sight. [if eyesight is good, then we assign a value of 1, else 0]
So if a person's height is greater than 4.5 feet but has good eyesight, then their risk is 70% (if they have bad eyesight, then risk is 90%).
In this case, we will need to use a nested if else statement to account for the new question. Here is what it will look like:
((Q1 < 4.5)? 50 : ((Q2 == 1) ? 70 : 90))
This statement can be paraphrased as: if height is <4.5 feet, the risk is 50%, but if height >=4.5 feet and eyesight is good, then risk is 70%, else it is 90%
So on and so forth
Just like this, you can create as many else if statements to account for more variables and complications.
To use If Else statements the basic syntax is "((x>0)? y : z)". This says if X is greater than 0, show Y otherwise show Z. Let's use it using an example for "or" and "and" statement for better understanding:
Suppose there that for all values of Q1 (value of question 1 is contained in Q1) less than 0 or greater than 10 the Result (R1) is 0. The solution for this one would be:
This handles the two ends of the ranges on the far left and far right.
Now lets assume for Q1 between 0 and 5, R1 (result 1) is fixed at 20. The solution for this one would be:
Now when Q1 is between 5 and 10, R1 goes down linearly from 20 to 0. So imagine value of R1 at 20 when Q1 is 5, at 0 when is 10 and then at Q1 is 7.5, R1 should be at the midpoint so 10. The reason it is in the midpoint is because it goes down linearly.
So, over 5 points of Q1 Result 1 goes down 20. Thus, for every one point change in "X" from 5, "Y" goes down by 20/5 (or 4). So 4 points reduction for every (Q1-5) point, we can restate this to say that R1 goes down from 20 by the amount 4*(Q1-5).This is the reduction amount from 20, hence, the formula for R1 for Q1 between 5 and 10 would be "20-4x(Q1-5)". Thus, the solution for this would be:
To handle "in between" conditions, we should always use greater than (>) and less than (<) symbols and make sure to be careful that the same endpoint is not included in two conditions.
For example: Income if income from X to Y has tax of 10% and income from Y to Z has tax of 20%. Y cannot be part of both ranges, so Y must either be 10% or 20%. In this case lets assume Y is 20%, then we must not include Y in the first range, we do this by using the strictly less than (<) symbol for the first range and then (>=) symbol in the second range.
Here is an example assume Q2 is the question asking a user for his/her income (notice Y is only in the second condition below):
- For "and" and "or" statements we always have at least two conditions before a question mark (?). Its important to write both conditions in separate parentheses so that the if statement knows there are two conditions and not just one.
Let us consider this example - do you know what is wrong with this writing here: ((Q1<20)and(Q1>10)?5:0)
What appears before the question mark is (Q1>10). But we don't want to say If Q1>10. We want to say if Q1 is > 10 and Q1 < 20
So we need to put that in parentheses for both conditions so the if statement knows the condition is not just Q1>10.
So the correct format is: (((Q1<20)and(Q1>10))?5:0).
- Using Parentheses with simple if else statement: Since there is only one condition in a simple if else statement, then only one set of parentheses is required for that condition.
For Example: Let's say if Q1 is 0 then then the output should be 10+Q1 else 0.
Feel free to reach out if you need more help.
In case the documentation below doesn't answer your questions about your formula, feel free to email [email protected]. Many of us are Mathematics majors and will be delighted to help :)
Now you can use date variables in Formulas on your calculator -
Use DD for current date
Use MM for current month
and Use YYYY for current year
Feel free to email [email protected] if you need any help with the formula. We will be delighted to help :)
Updated almost 2 years ago