PI() takes no argument and returns π, 3.141592653589793. DuckDB and Snowflake have pi(); BigQuery has no PI function, and ACOS(-1) gives the same number. The trap is the shortcut: 3.14 or 3.1416 in hand-written SQL makes every area and angle slightly different from Tableau's.
Updated · Checked on the xmetric engine
What is the syntax?
PI()
(none)
PI takes no arguments, but the parentheses are required.
Returns the number π (3.141592653589793).
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 does PI() return on every row?
Tableau
PI()
SQL (DuckDB)
SELECTpi() AS result
FROM input
ORDERBY id
The same constant on each of the 8 rows.
Result
3.14
3.14
3.14
3.14
3.14
3.14
3.14
3.14
✓ The Tableau formula and the SQL return the same 8 rows.
What is the area of a circle with each value as its radius?
Tableau
PI() *SQUARE([Value])
SQL (DuckDB)
SELECTpi() * Value * Value AS result
FROM input
ORDERBY id
A radius of 16 gives 804.25; the null row stays null.
Value
Result
2.5
19.63
−2.5
19.63
0.13
0.05
−0.4
0.5
3.75
44.18
null
0
0
16
804
✓ The Tableau formula and the SQL return the same 8 rows.
Where does a straight translation go wrong?
Common mistake
Why is the area slightly off with 3.14?
Hard-coding 3.14 shaves 0.05% off every result: a radius of 16 gives 803.84 instead of Tableau's 804.25.
Tableau
PI() *SQUARE([Value])
Tempting SQL
SELECT3.14* Value * Value AS result
FROM input
ORDERBY id
SQL that matches
SELECTpi() * Value * Value AS result
FROM input
ORDERBY id
Value
Tableau
Tempting SQL
SQL that matches
2.5
19.63
19.63
19.63
−2.5
19.63
19.63
19.63
0.13
0.05
0.05
0.05
−0.4
0.5
0.5
0.5
3.75
44.18
44.16
44.18
null
null
null
0
0
0
0
16
804
804
804
✓ 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
SELECTPI() *SQUARE(Value) AS result
FROM input
ORDERBY id