Overview
1. Function Definition
The SWITCH function can make judgements on multiple conditions and return corresponding results based on different values.

Syntax | SWITCH(Expression,Value1,Result1,Value2,Result2,...,Other results) | If the result of the expression is Value1, the function returns Result1. If the result of the expression is Value2, the function returns Result2. If there is no matching value, the function returns other results. |
Parameter 1 | Expression | – |
Parameter 2 | Result | Result1, Result2..., and Other results, must be the same type of data. Other results can be the default value. In this case, if the expression value does not have a corresponding result, the function will return empty. |
2. Notes
At least three parameters are required.
At least 3 parameters are required for real-time data, and the result parameters must be of the same type.
If the parameter is of the date type, the function needs to nest a date function inside, for example, SWITCH(Date,TODATE("2022/01/01"),"1")
3. Example
Formula | Result | Note |
SWITCH(1+2,3,"today is Wednesday",4,"today is Thursday") | Today is Wednesday | – |
SWITCH(5,3,"Today is Wednesday",4,"Today is Thursday","Friday") | Friday | – |
Example
When you need to judge many conditions, it may be cumbersome to use the IF function to judge each condition. In this case, the SWITCH function can be used for multiple condition assignment.
For example, you can set the class name by the SWITCH function. If the current value is Class1, display "Class A"; if it is Class2, display "Class B"; if it is Class3, display "Class C"; otherwise, display "Class D".
Sample Data:Score Table.xlsx
Adding Data
1. Upload Score Table to FineBI. Click My Analysis and click New Analysis. Click Local Excel > Upload Data in the pop-up box, as shown in the following figure.
2. After clicking Upload Data, click OK to upload the data and create the analysis subject, as shown in the following figure.
Perform Condition Assignment
1. Open the dataset editing page, click Formula Column, and enter SWITCH(Class,"Class1","Class A","Class2","Class B","Class3","Class C","Class D"). Enter the column name as Class in Alphabetical Order, and click OK, as shown in the following figure.

2. The following table describes the formula.
Formula | Description |
SWITCH(Class,"Class1","Class A","Class2","Class B","Class3","Class C","Class D") | If the data is Class1, it will be assigned as Class A; if it is Class2, it will be assigned as Class B; if it is Class3, it will be assigned as Class C; otherwise, the result will be displayed as Class D. |
Effect Display
The following figure shows the effect.