In this tutorial, you will learn How to Write a Case Statement in Google Sheets.
A case statement is a particular kind of statement which cycles through specified conditions and returns a value.
To write a caste statement in Google Sheets you can use the SWITCH() function.
Following is the SYNTAX for the SWITCH() function
SWITCH(expression, case1, value1, [case2, value2, ...], [default])
Example Usage :
SWITCH(A1:A10, 0, “No”, 1, “Other”) SWITCH(A3:A8, 4, “Four”, 8, “Eight”)
This particular function looks at cell A2:A10, If the value is 0 it will return “No” else in case of 1 it will return Other.
In the second example, it looks at cell A3:A8,, If the value is 4 it will return “Four” else in the case of 8 it will return “Eight”.
How to Write a Case Statement in Google Sheets: Step-by-Step Guide
Here are the steps to write a Case Statement in Google Sheets :
Step 1: Open Google Sheets and prepare your dataset.
We will use the following dataset which has two columns Grade and Passed
Now we are going to use the SWITCH() function to get the passed result in Column B by using the values from Column A:
Select the cell where you need to apply the formula in our example cell B2 and paste the formulas in the function fx area(adjust the formula as per your data)
Now the Passed result has been returned using the SWITCH () function and specified conditions.
The formula has been applied to all the cells in the Column using the Google Auto-complete feature.
How to Write a Case Statement in Google Sheets(Conclusion)
In the above tutorial, we have shown you a step-by-step guide using which you can easily use a SWITCH function in Google Sheets.
We hope this tutorial on How to Write a Case Statement in Google Sheets is helpful.
Related articles :
How to Insert Spin Button in Google Sheets ( Easy Guide )
How to Freeze Rows in Google Sheets
How to Calculate Square Root and Cube Root in Google Sheets(Quick & Easy Guide)
How to use SUMSQ Function in Google Sheets(Quick & Easy Guide )