Hey Coda, can you check if something is true for me? And if it is, do one thing, if it’s false, do a different thing.
SwitchIf()
Gets a value conditionally (multiple conditions, multiple references)
put a bit simpler...
Hey Coda, can you check a lot of different things for me? And then simply the first true thing you find?
Switch()
Gets a value conditionally (multiple conditions, one reference)
put a bit simpler...
Hey Coda, can you look at a single condition or cell in my doc. Then depending on what it is, I’ll what a different output.
If you end up creating a Coda document without one of these formulas, please email and let me know. These formulas allow you to conditionally change the output.
How Do These Work?
Getting conditional values, Let’s look at what that actually means by testing out the blue toggle below
In plain language, a condition is simply the current state of something. In the example above, the condition is whether the toggle is on or off.
If() : Single condition, Multiple References
Road Bikes
Mountain Bikes
Road Bikes
Road bikes differ from others in that they have firm frames that allow more of the effort placed into the pedals to translate to forward movement.
In the example above, the text inside the gray box is being controlled by a condition, specifically the condition of the toggle and whether it is on or off. When we say “condition” we simply mean the current state of something.
When we talk about weather conditions, we are talking about the current state of the weather outside, whether it is hot, cold, or windy. Try the slider below to see how the message will change based on the weather. See how many different messages you can output.
The Temperature outside today is
000
32
degrees
: Expect Rain
Suggested Attire
Wear a heavier jacket - The cold will be pretty biting without a few extra layers of protection.
If you click into the formula that constructs the sentence, you will notice that each condition is referencing multiple things. Whenever you want to reference more than one thing and you want multiple conditions, use SwitchIf().
Switch(): Multiple Conditions, Single reference
Try typing any sentence you can think of into the yellow column below. Watch what output you get in the gray column below thanks to Switch()
Sentence
Capitalized Vowels
Sentence
Capitalized Vowels
1
There are no rows in this table
0
0
This lesson was made using Switch!
[ ]
Practice: Try using If() to change a message based off how much money you made
Done
Write a formula that will return a student’s letter grade based off their percentage grade