Skip to content

Instantly share code, notes, and snippets.

@ninmonkey
Last active September 13, 2026 20:14
Show Gist options
  • Select an option

  • Save ninmonkey/7f204f8d3da0bc0f87c2c7199c3df092 to your computer and use it in GitHub Desktop.

Select an option

Save ninmonkey/7f204f8d3da0bc0f87c2c7199c3df092 to your computer and use it in GitHub Desktop.
DAX - Sign Operator Precedence - Exponents.md

Dax Comparing operator precedence for exponents

Live demo: https://dax.do/k1CMcd5fRbo6ax/

Do these DAX expressions equal the same thing? Or do they differ?

(-10) ^ 2

verses

  -10 ^ 2

Give it a test

-- 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

Results

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

TL;DR

Yes, they are not the same

Additional links

-- 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 ( {
("-10 * -10", -- 100
-10 * -10 ),
("-10 ^ 2",
-10 ^ 2 ), -- -100
("(-10) ^ 2",
(-10) ^ 2 ), -- 100
("base", base ),
("baseNeg", baseNeg ),
("base ^ 2",
base ^ 2 ), -- 36
("-base ^ 2",
-base ^ 2 ), -- -36
("(-base) ^ 2",
(-base) ^ 2 ), -- 36
("baseNeg ^ 2",
baseNeg ^ 2 ), -- 6
("-baseNeg ^ 2",
-baseNeg ^ 2 ), -- -36
("(-baseNeg) ^ 2",
(-baseNeg) ^ 2 ) -- 36
} )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment