Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Does anyone know if there is a DAX function similar to the Excel function XOR:
XOR(logical1, [logical2],…)
The XOR function syntax has the following arguments.
Logical1, logical2,… Logical 1 is required, subsequent logical values are optional.
Solved! Go to Solution.
Hi @Anonymous
You could obtain the same behavior by doing something like
Condition1 + Condition2 + ... + Condition N = 1
where Condition K are booleans. The exact implementation will depend on your particular case. For instance, imagine you have a colum with numbers
XOR (NumberRow1 = 25, NumberRow2 = 25,..., NumberRowN = 25) would be
SUMX(Table1, Table1[Number] = 25) = 1
If this doesn't help show the details of your particular case and we' ll have a look
Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.
Cheers
Hi @Anonymous
SteveCampbell and AlB 's suggestions should point the right direction.
If you have problem to implement it for your scenario, please share an exmaple here so that i can test and provide a valid solution.
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Essentially, XOR counts the number of TRUE arguments and returns TRUE if it is odd.
Here's one way to replicate:
Power BI will implicitly cast TRUE to 1 and FALSE to 0 if we multiply by 1.
We can put all our consitions into a table, then use a SUMX to iterate through, multiply each condition by 1 and sum the result.
Then we can use the MOD function and divide by two to check if it is even or odd.
XOR = VAR _Conditions = { ///ENTER EACH CONDITION HERE, SEPERATED BY COLUMN // 1=1, 1=2,
4>6,
[Measure1] = 5,
SELECTEDVALUE(TABLE[Column1]) = "Some Value",
///END EDITING HERE// } RETURN MOD(
CALCULATE( SUMX(_Conditions,[Value]*1))
,2) = 1
The red text is where you enter your conditions. the curly brackets {} will put them into an in memory table. You can put as many as you want, but seperate each one by a comma. I've added some examples of valid conditions, so remove the red and replace with your own.
Love hearing about Power BI tips, jobs and news?
I love to share about these - connect with me!
Stay up to date on
Read my blogs on
Did I answer your question? Mark my post as a solution! Proud to be a Super User!
Connect with me!
Stay up to date on
Read my blogs on
Hi @Anonymous
You could obtain the same behavior by doing something like
Condition1 + Condition2 + ... + Condition N = 1
where Condition K are booleans. The exact implementation will depend on your particular case. For instance, imagine you have a colum with numbers
XOR (NumberRow1 = 25, NumberRow2 = 25,..., NumberRowN = 25) would be
SUMX(Table1, Table1[Number] = 25) = 1
If this doesn't help show the details of your particular case and we' ll have a look
Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.
Cheers
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |