反馈已提交

网络繁忙

You are viewing 5.1 help doc. More details are displayed in the latest help doc.

Switch

  • Recent Updates: April 15, 2022
  • 1. Overview

    1.1 Problem description

    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.

    30.png

    1.2 Implementation idea

    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.

    1.3 Function description

    Judgment of multiple cases, used in cases where there are many judgment conditions.

    1)Overview

    GrammarSWITCH(expression,value1,result1,value2,result2,……)If the result of the expression is the value 1, the whole function returns the result 1 If the result of the expression is the value 2, the whole function returns the result 2, if the result of the expression is the value 3, the whole function returns the result 3, etc.
    parameter1expression-
    parameter2resultAll of result 1, result 2, result 3 ...... must be the same type of data.

    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

    FormulaResultRemarks
    SWITCH(1+2,3,"Today Wednesday",4,"Today Thursday")Today Wednesday

    2. Example

    Example data: switch function use.xlsx

    2.1 Create a Self-service dataset

    Go to Data Preparation and add the sample data to BI.

    Create the Self-Service dataset as shown in the following figure.

    20.png

    2.2 Add new column

    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.2.png

    Note: The city in the formula is not entered manually, but selected by clicking in the field on the left.  

    2.3 Data preview

    The effect of the data can be seen in the preview data box as shown in the following figure.3.png

    Click the "Save" button in the upper right corner and update the data to use the city name field in the front-end analysis.

    Attachment List


    Theme: Advanced Data Analyis
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    售前咨询电话

    400-811-8890转1

    在线技术支持

    在线QQ:800049425

    热线电话:400-811-8890转2

    总裁办24H投诉

    热线电话:173-1278-1526

    文 档反 馈

    鼠标选中内容,快速反馈问题

    鼠标选中存在疑惑的内容,即可快速反馈问题,我们将会跟进处理。

    不再提示

    10s后关闭