QBoard » Advanced Visualizations » Viz - Tableau » Tableau Calculation IF statement

Tableau Calculation IF statement

  • **New to Tableau

    I am trying to create a new column for that changes a cell to say 'Open' when it is equal to 0.

    Currently I have this, but I can't compare an int and a string.

    IF  [Carton Count] = 0 
    THEN [Carton Count] = 'Open'
    ELSE [Carton Count]
    END

     

    Any way to possibly do this without changing the SQL?

     
      October 11, 2021 12:57 PM IST
    0
  • Ended up just editing the SQL.

    ,CASE   
    WHEN (CAST(COUNT(DISTINCT CARTON_ID) as varchar(10))) = '0'
    THEN 'Open'
    ELSE (CAST(COUNT(DISTINCT CARTON_ID) as varchar(10)))
    END AS CARTON_COUNT



      October 13, 2021 2:01 PM IST
    0
  • Tableau If Statement Example

    The Tableau If statement returns the result only if the given condition is True; otherwise, it returns nothing.

    To demonstrate this Tableau If function, we need a Calculated Field. To create a calculated field, please navigate to Analysis Tab and select the Create Calculated Field… option, as shown below.

    Once you click on the Create Calculated Field… option, the following window will be opened. Here, we renamed the default calculation name as If Exam. And the code is

    IF(SUM([Profit]) > 0) THEN 'Performing Good'
    END

    Let me add this calculated field to the table (by dragging a field to Rows Shelf) that we created earlier. Please refer Create Table Report article to understand the steps involved in creating a table

      October 25, 2021 2:12 PM IST
    0