Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Santhsk
Regular Visitor

IF statment with && or || not working with mutiple arguments

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 : 

Column = IF(Sheet1[Col1] = "y" && (Sheet1[col2] <> "A" || Sheet1[col2] <> "B"),"True", "False")
Not getting the required result. Need helo
Col1col2
yA
yB
yC
xB
zE
yA
yD

 

Santhsk_0-1644162779395.png

 

1 ACCEPTED SOLUTION

Hi @Santhsk ,

result =
IF(
    AND(
        [col1] = "y",
        NOT ( [col2]
            IN {
            "A",
            "B"
        } )
    ),
    TRUE(),
    FALSE()
)

vchenwuzmsft_0-1644478549256.png

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.

 

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@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...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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()
)

vchenwuzmsft_0-1644478549256.png

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.

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors