ASIN(number) is the arcsine: the angle, in radians, whose sine is the number, so ASIN(1) is π/2. The input must be from -1 to 1. Outside that range Tableau gives null, while DuckDB's asin() raises an error, so the SQL guards it: CASE WHEN x BETWEEN -1 AND 1 THEN asin(x) END.
Updated · Checked on the xmetric engine
What is the syntax?
ASIN(number)
number
a number from -1 to 1, usually a sine or a ratio.
Returns a number of radians from -π/2 to π/2. Null if the input is null or outside -1 to 1.
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.
What angle has each ratio as its sine?
Tableau
ASIN([Ratio])
SQL (DuckDB)
SELECTCASEWHEN Ratio BETWEEN-1AND1THENasin(Ratio) ENDAS result
FROM input
ORDERBY id
1 gives π/2 (1.5708), -1 gives -π/2 and 0.5 gives π/6. Row 7 is 1.5, so it returns null.
Ratio
Result
0.5
0.52
−0.5
−0.52
1
1.57
−1
−1.57
0
0
null
1.5
null
−0.8
−0.93
✓ The Tableau formula and the SQL return the same 8 rows.
What is that angle in degrees?
Tableau
DEGREES(ASIN([Ratio]))
SQL (DuckDB)
SELECTCASEWHEN Ratio BETWEEN-1AND1THENdegrees(asin(Ratio))
ENDAS result
FROM input
ORDERBY id
0.5 gives 30 degrees and -1 gives -90.
Ratio
Result
0.5
30
−0.5
−30
1
90
−1
−90
0
0
null
1.5
null
−0.8
−53.13
✓ The Tableau formula and the SQL return the same 8 rows.
Where does a straight translation go wrong?
Common mistake
Why does clamping the input give an angle where Tableau gives null?
Clamping the ratio into -1 to 1 silences DuckDB's error but turns row 7's 1.5 into 1, so the SQL returns π/2 where Tableau returns null. Keep the out-of-range rows null with CASE.
Tableau
ASIN([Ratio])
Tempting SQL
SELECTasin(least(1, greatest(-1, Ratio))) AS result
FROM input
ORDERBY id
SQL that matches
SELECTCASEWHEN Ratio BETWEEN-1AND1THENasin(Ratio) ENDAS result
FROM input
ORDERBY id
Ratio
Tableau
Tempting SQL
SQL that matches
0.5
0.52
0.52
0.52
−0.5
−0.52
−0.52
−0.52
1
1.57
1.57
1.57
−1
−1.57
−1.57
−1.57
0
0
0
0
null
−1.57
null
1.5
null
1.57
null
−0.8
−0.93
−0.93
−0.93
✓ 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
SELECTCASEWHEN Ratio BETWEEN-1AND1THENASIN(Ratio) ENDAS result
FROM input
ORDERBY id