Search code examples
mysqltableau-api

Tableau creating calculating column for whole table


Is tableau has a opportunity to create calculated column for table? For example here are 2 column with some number and I want to make third column with formula like this If(column1>column2;column1;column2. I see there is option to create calculated field with summarize columns but I just want to compare them.


Solution

  • If you only want to create a new column storing the max between 2 original column, you just need to create a calcultaed field like the following:

    if column1 > column2
    then column1
    else column2
    end
    

    EDIT Or even simpler

    MAX([column1], [column2])
    

    There are two (overloaded) functions named MAX(). With one argument, MAX() is an aggregate function that operates on a column of values and returns the maximum - just like other aggregate functions like SUM(), AVG() etc. With two arguments, MAX() is a record level function that operates on an individual data row and returns the larger of its two arguments. MIN() behaves similarly.