When there are many conditions that need to be judged, it will be more troublesome to use IF function to judge each case, so you need to nest layers and write multiple expressions.
For example, there are two fields in the summary table, a city code, a sales, you need to convert the city code to a city name.
In this case, you can use the switch function to determine multiple cases by writing just one expression.
SWITCH(expression, value1, result1, value2, result2, ... )
If the result of the expression is value 1, the whole function returns result 1.
if the result of the expression is value 2, the whole function returns result 2.
if the result of the expression is value 3, the entire function returns result 3.
Note: Adding else judgments to the Switch function is not supported.
Judgment of multiple cases, used in cases where there are many judgment conditions.
1)Overview
2)Cautions
At least three parameters.
Note: The number of parameters in the real-time data is at least 3, and the resultant parameters are of the same type.
3)Example
Example data: switch function use.xlsx
Go to Data Preparation and add the sample data to BI.
Create the Self-Service dataset as shown in the following figure.
In the new Self-Service dataset, select "New Column", edit the formula: SWITCH(City, "Wan A", "Hefei", "Wan B", "Wuhu", "Wan C", "Bengbu", "Wan D", "Wan South", "Wan E", "Maanshan") and select the new column type as "Text", enter the new column name and click "OK", the following figure shows.
Note: The city in the formula is not entered manually, but selected by clicking in the field on the left.
The effect of the data can be seen in the preview data box as shown in the following figure.
Click the "Save" button in the upper right corner and update the data to use the city name field in the front-end analysis.
滑鼠選中內容,快速回饋問題
滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。
不再提示
10s後關閉
Submitted successfully
Network busy