Gallery
If, SwitchIf, Switch
Share
Explore

icon picker
If, SwitchIf, Switch

Formulas: If(), SwitchIf(), Switch()
Category: Logical
dust.svg
If()
Gets a value conditionally (single condition)
put a bit simpler...
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.

switch-off.svg
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?
back-sorting.svg
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
cycling-road

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.

SwitchIf():Multiple Conditions, Multiple references

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
chance-of-storm

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
1
There are no rows in this table
0
0
This lesson was made using Switch!
[ ]


Done
Write a formula that will return a student’s letter grade based off their percentage grade
Done
Done

Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.