What is a squared?
Tableau
[a] ^ 2SQL (DuckDB)
SELECT power(a, 2) AS result
FROM input
ORDER BY idRow 2: (-7)^2 is 49.
| a | Result |
|---|---|
| 7 | 49 |
| −7 | 49 |
| 2 | 4 |
| 9 | 81 |
| 5 | 25 |
| null | |
| 1 | 1 |
| −3 | 9 |
The Tableau formula and the SQL return the same 8 rows.
Tableau function Operators
[a] ^ 2 raises a to the power 2, like power(a, 2). In Tableau's precedence the minus sign binds tighter than ^, so -[a] ^ 2 is (-a)^2, always positive. DuckDB's -a ^ 2 agrees; rewriting it as -power(a, 2) flips the sign.
a ^ ba, bReturns a number: a raised to the power b. Null if either side is null.
Each example runs on the same 8 sample rows twice: the Tableau formula on the xmetric engine, and the SQL in DuckDB.
Tableau
[a] ^ 2SQL (DuckDB)
SELECT power(a, 2) AS result
FROM input
ORDER BY idRow 2: (-7)^2 is 49.
| a | Result |
|---|---|
| 7 | 49 |
| −7 | 49 |
| 2 | 4 |
| 9 | 81 |
| 5 | 25 |
| null | |
| 1 | 1 |
| −3 | 9 |
The Tableau formula and the SQL return the same 8 rows.
Common mistake
-power(a, 2) come out negative?Tableau applies the minus before ^, so -[a] ^ 2 squares -a. -power(a, 2) squares first and negates after. Move the minus inside: power(-a, 2).
Tableau
-[a] ^ 2Tempting SQL
SELECT - power(a, 2) AS result
FROM input
ORDER BY idSQL that matches
SELECT power(- a, 2) AS result
FROM input
ORDER BY id| a | Tableau | Tempting SQL | SQL that matches |
|---|---|---|---|
| 7 | 49 | −49 | 49 |
| −7 | 49 | −49 | 49 |
| 2 | 4 | −4 | 4 |
| 9 | 81 | −81 | 81 |
| 5 | 25 | −25 | 25 |
| null | null | null | |
| 1 | 1 | −1 | 1 |
| −3 | 9 | −9 | 9 |
The SQL that matches returns the Tableau result on every row; the marked cells are where the tempting SQL differs.
The first example, written for each warehouse from its documentation. These are not run here; DuckDB is.
Edit the formula and run it on the 8 sample rows. Fields: [id], [a], [b], [x], [p], [q], [s], [t], [d], [e].
Runs in your browser on the xmetric engine. Nothing is uploaded.
[a] ^ [b] and POWER([a], [b]) return the same value; only the precedence of a leading minus differs.
Left to right: (2 ^ 3) ^ 2 = 64. Add parentheses when you mean 2 ^ 9.
No. Use POWER; in BigQuery ^ is bitwise XOR.