Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Your file has been submitted successfully. We’re processing it now - please check back in a few minutes to view your report.
In my recent quest to create or catalog as many DAX equivalents for Excel functions, with DEC2BIN and BIN2DEC figured out and combining this with the work on XOR and BITOR we can implement a bitwise XOR function, BITXOR:
BITXOR =
VAR __Decimal1 = SELECTEDVALUE('Decimal1'[Decimal1],0)
VAR __Decimal2 = SELECTEDVALUE('Decimal2'[Decimal2],0)
RETURN
SWITCH(TRUE(),
__Decimal1 = 0,__Decimal2,
__Decimal2 = 0,__Decimal1,
VAR __Table1 =
ADDCOLUMNS(
GENERATESERIES(0,LOG(__Decimal1,2),1),
"Bit",MOD(TRUNC(__Decimal1 / POWER(2,[Value])),2)
)
VAR __Table2 =
ADDCOLUMNS(
GENERATESERIES(0,LOG(__Decimal2,2),1),
"Bit",MOD(TRUNC(__Decimal2 / POWER(2,[Value])),2)
)
VAR __Table =
ADDCOLUMNS(
ADDCOLUMNS(
GENERATESERIES(0,MAXX({ COUNTROWS(__Table1), COUNTROWS(__Table2) },[Value]) - 1),
"Xor",IF(
MAXX(FILTER(__Table1,[Value] = EARLIER([Value])),[Bit]) =
MAXX(FILTER(__Table2,[Value] = EARLIER([Value])),[Bit])
,0,1
)
),
"Decimal",POWER(2,[Value]) * [Xor]
)
RETURN
SUMX(__Table,[Decimal])
)
NOTE: Just like the original Excel BITXOR function, does not support negative numbers as inputs.
eyJrIjoiYWMzOGJhZTctODg1OC00YWM3LWE5MTgtMzgyZTljNGU5ZDZkIiwidCI6IjRhMDQyNzQzLTM3M2EtNDNkMi04MjdiLTAwM2Y0YzdiYTFlNSIsImMiOjN9