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

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.

Reply
Anonymous
Not applicable

Dax mix of && and || in IF statement

Curious about how to mix && and || in IF statements. Ie- IF a=value1, b=value2, c=value3 OR d=value4 OR e=value5. In other words, if these three things are true or either of these other two things are true, than 1 else 0. Are parenthesis needed in some way to make this work?

 

Ex., convert OR's and And's in this statement (And's are already done but may need parenthesis changes): 

[Field] = IF(OR(OR(OR(RELATED('Dim - Product'[Class ID])=628 && RELATED('Dim - Product'[Subclass ID]) = 1519 && 'Fact - POS'[Config_Type] =7,RELATED('Dim - Product'[Class ID]) = 133),RELATED('Dim - Product'[Class ID])=265),RELATED('Dim - Product'[Class ID])=268)=True,1,0)

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @Anonymous

 

Have a good look at the SWITCH statement.  It's really versatile.

 

The essence is :

Result = SWITCH (
           True() ,
            A = B && C = D , 1
            A = B || C = D , 2
            ---- ELSE ----
            999
           )

 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

1 REPLY 1
Phil_Seamark
Employee
Employee

Hi @Anonymous

 

Have a good look at the SWITCH statement.  It's really versatile.

 

The essence is :

Result = SWITCH (
           True() ,
            A = B && C = D , 1
            A = B || C = D , 2
            ---- ELSE ----
            999
           )

 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.