ATAN: from Tableau to SQL

Returns the inverse tangent in radians. Below, 8 sample rows go through the calculation and through the SQL, and both return the same numbers.

Calculated field

ATAN([score])

Sample data

idamountunitsscoreother
1-2.52-0.83
20004
31.530.252
4440.58
5950.811
6166114
7null7null9
848-0.5null

The same calculation as SQL

SELECT atan(score) AS result FROM input ORDER BY id

Runs the example above.

Result

idamountunitsscoreresult
1-2.52-0.8-0.674741
20000
31.530.250.244979
4440.50.463648
5950.80.674741
616610.785398
7null7nullnull
848-0.5-0.463648

Same rows from the calculation and from the SQL in DuckDB.

Where a naive translation goes wrong

  • Replacing null results with zero changes missing-value semantics.

    Naive SQL

    SELECT coalesce((atan(score)),0) AS result FROM input ORDER BY id
    idamountunitsscoreresult
    1-2.52-0.8-0.674741
    20000
    31.530.250.244979
    4440.50.463648
    5950.80.674741
    616610.785398
    7null7null0
    848-0.5-0.463648

    Matches the calculation

    SELECT atan(score) AS result FROM input ORDER BY id
    idamountunitsscoreresult
    1-2.52-0.8-0.674741
    20000
    31.530.250.244979
    4440.50.463648
    5950.80.674741
    616610.785398
    7null7nullnull
    848-0.5-0.463648

Signature

ATAN(number)