Live demo: https://dax.do/k1CMcd5fRbo6ax/
Do these DAX expressions equal the same thing? Or do they differ?
(-10) ^ 2
verses
-10 ^ 2
-- testing order of operations
-- see: https://dax.guide/operators
-- https://learn.microsoft.com/en-us/training/modules/dax-power-bi-write-formulas/5-operators
define
var base = 6
var baseNeg = -6
EVALUATE ( {
("a", -10 * -10 ), -- 100
("b", -10 ^ 2 ), -- -100
("b", (-10) ^ 2 ), -- 100
("c", -base ^ 2 ), -- -36
("c", baseNeg ^ 2 ), -- 6
("c", -baseNeg ^ 2 ) -- -36
} )Note
There's a longer DAX script at the bottom. It was used to make the the screenshot
| DAX | Result |
|---|---|
-10 * -10 |
100 |
-10 ^ 2 |
-100 |
(-10) ^ 2 |
100 |
| DAX | Result |
|---|---|
base |
6 |
baseNeg |
-6 |
base ^ 2 |
36 |
-base ^ 2 |
-36 |
baseNeg ^ 2 |
36 |
-baseNeg ^ 2 |
-36 |
Yes, they are not the same
- operator precedence rules
- confirmation with wolframalpha: https://www.wolframalpha.com/input?i=-10+**+2
