Tableau function Number

Tableau RADIANS to SQL

RADIANS(number) turns degrees into radians: RADIANS(180) is π. Tableau's SIN, COS and TAN take radians, so this is the usual first step for angles stored in degrees. DuckDB and Snowflake have radians(); BigQuery doesn't, so multiply by ACOS(-1) / 180. Don't hard-code 3.14.

Updated · Checked on the xmetric engine

What is the syntax?

RADIANS(number)
number
an angle in degrees.

Returns a number of radians. Null if the input is null.

What does it return, and what is the SQL?

Each example runs on the same 8 sample rows twice: the Tableau formula on the xmetric engine, and the SQL in DuckDB.

How many radians is each angle?

Tableau

RADIANS([Value])

SQL (DuckDB)

SELECT radians(Value) AS result
FROM input
ORDER BY id

Value is read as degrees: 16 degrees is 0.279 radians, 2.5 degrees is 0.0436.

ValueResult
2.50.04
−2.5−0.04
0.130
−0.4−0.01
3.750.07
null
00
160.28

The Tableau formula and the SQL return the same 8 rows.

What is the cosine of a quantity of 45-degree steps?

Tableau

COS(RADIANS([Qty] * 45))

SQL (DuckDB)

SELECT cos(radians(Qty * 45)) AS result
FROM input
ORDER BY id

8 steps make a full turn: Qty 2 is 90 degrees, cosine 0 (to floating-point precision), and Qty 4 is 180 degrees, cosine -1.

QtyResult
70.71
−70.71
100
90.71
20
4−1
−10.71
01

The Tableau formula and the SQL return the same 8 rows.

Where does a straight translation go wrong?

Common mistake

Why are the radians slightly off with 3.14?

Hard-coding π as 3.14 undershoots by 0.05%: 16 degrees becomes 0.27911 instead of 0.27925. Use radians() or pi().

Tableau

RADIANS([Value])

Tempting SQL

SELECT Value * 3.14 / 180 AS result
FROM input
ORDER BY id

SQL that matches

SELECT radians(Value) AS result
FROM input
ORDER BY id
ValueTableauTempting SQLSQL that matches
2.50.040.040.04
−2.5−0.04−0.04−0.04
0.13000
−0.4−0.01−0.01−0.01
3.750.070.070.07
nullnullnull
0000
160.280.280.28

The SQL that matches returns the Tableau result on every row; the marked cells are where the tempting SQL differs.

How do I write it in Snowflake or BigQuery?

The first example, written for each warehouse from its documentation. These are not run here; DuckDB is.

Snowflake

SELECT RADIANS(Value) AS result
FROM input
ORDER BY id

Snowflake documentation

BigQuery

SELECT Value * ACOS(- 1) / 180 AS result
FROM input
ORDER BY id

BigQuery documentation

What does your own RADIANS formula return?

Edit the formula and run it on the 8 sample rows. Fields: [id], [Region], [Value], [Qty], [Ratio], [Other].

Runs in your browser on the xmetric engine. Nothing is uploaded.

Which functions go with it?

What do people ask about RADIANS?

When do I need RADIANS?

Whenever an angle in degrees goes into SIN, COS, TAN or COT: COS(RADIANS([Bearing])).

How do I convert back?

DEGREES([Radians]); in SQL degrees(x).

What does RADIANS return for a null?

Null. Row 6 has no value.

Where is this documented?