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!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
IF statment with && or || not working with mutiple arguments:
Data set: Required Result : IF Col1 = Y AND Col2 <> A OR Col2 <> B then True else False.
I tried with below query :
Col1 | col2 |
y | A |
y | B |
y | C |
x | B |
z | E |
y | A |
y | D |
Solved! Go to Solution.
Hi @Santhsk ,
result =
IF(
AND(
[col1] = "y",
NOT ( [col2]
IN {
"A",
"B"
} )
),
TRUE(),
FALSE()
)
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Santhsk Not sure what you are expecting but the results you are getting are 100% accurate given your formula and stated logic. Perhaps you meant to state your logic as:
IF Col1 = Y AND Col2 <> A AND Col2 <> B then True else False
like:
Column = IF(Sheet1[Col1] = "y" && (Sheet1[col2] <> "A" && Sheet1[col2] <> "B"),"True", "False")
Think about it, with the OR in there then if the first column is y then it will always return true because A is not B and B is not A and any other letter is also not B or A. So...
Appreciate for your quick respone. Looking for the below result :
If ( Col1 = y, col2 not equal to A, col2 not equal to B) Then return True else False.
Please refer the screen shot
OUTPUT: Col1 = y , Col2 = A then False
Col1 = y, Col2 <> B then True
Col1 = X , Col2 = C then False
Hi @Santhsk ,
result =
IF(
AND(
[col1] = "y",
NOT ( [col2]
IN {
"A",
"B"
} )
),
TRUE(),
FALSE()
)
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.