Greg_Deckler's avatar
Greg_Deckler
Community Champion
6 years ago

XOR

In my recent quest to create or catalog as many DAX equivalents for Excel functions, here's an obvious one missing from DAX's logical functions library, the ever popular XOR.

XOR = 
    VAR __Logical1 = MAXA([Logical1])
    VAR __Logical2 = MAXA([Logical2])
    VAR __Table = { CONVERT(__Logical1, BOOLEAN), CONVERT(__Logical2, BOOLEAN) }
    VAR __TrueRows = COUNTROWS(FILTER(__Table,[Value] = TRUE()))
RETURN
    IF(ISEVEN(__TrueRows),FALSE,TRUE)

I have structued this so that it can be easily extended to support any number of logical "input" arguments. Essentially, just add as many items to __Table as desired.

No RepliesBe the first to reply