Don't miss your chance to take exam DP-600 or DP-700 on us!
Request nowLearn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register 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