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
AlexAlberga727
Resolver II
Resolver II

OR Statement not working as expected. What am I doing wrong?

I have been utilizing the below IF statement - and it works as expected. However, I now need to add an additional parameter to check for Orders that also now start with a "T".

Drop-Ship/Warehouse Order Filter = 
IF( 
        fSales[CustomerID] = "Amazon" && LEFT(fSales[PO],1) <> "U"  ,
            "Warehouse Order",
            "Drop-Ship Order")

 

When I add in this additional parameter the formula no longer works. Please help. Below is the formula I have created, and have also tried other ways and I feel as if Im not aware of something.

 

Drop-Ship/Warehouse Order Filter = 
IF( 
        fSales[CustomerID] = "Amazon" && LEFT(fSales[PO],1) <> "U" || fSales[CustomerID] = "Amazon" && LEFT(fSales[PO],1) <> "T" ,
            "Warehouse Order",
            "Drop-Ship Order")

 

Please let me know if there is a better way of doing so. Maybe SWITCH will work better. I'll start futsing around with SWITCH.

 

Thanks in advance!

1 ACCEPTED SOLUTION

@AlexAlberga727 , I can't catch you with what you described in your first post,

... add an additional parameter to check for Orders that also now start with a "T".

You mean NOT starts with "T" either, right?

You might try to author it this way,

Drop-Ship/Warehouse Order Filter =
IF (
    fSales[CustomerID] = "Amazon"
        && NOT LEFT ( fSales[PO], 1 ) IN { "U", "T" },
    "Warehouse Order",
    "Drop-Ship Order"
)

//if fSales[CustomerID] is "Amazon" and fSales[PO] doesn't start with "U" or "T", then "Warehouse Order", else "Drop-Ship Order"

 

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

6 REPLIES 6
AlexAlberga727
Resolver II
Resolver II

@CNENFRNL Thanks for the infomation. However, do you have a solution to the problem I presented, or just throwing out information that im already following.

@AlexAlberga727 , I can't catch you with what you described in your first post,

... add an additional parameter to check for Orders that also now start with a "T".

You mean NOT starts with "T" either, right?

You might try to author it this way,

Drop-Ship/Warehouse Order Filter =
IF (
    fSales[CustomerID] = "Amazon"
        && NOT LEFT ( fSales[PO], 1 ) IN { "U", "T" },
    "Warehouse Order",
    "Drop-Ship Order"
)

//if fSales[CustomerID] is "Amazon" and fSales[PO] doesn't start with "U" or "T", then "Warehouse Order", else "Drop-Ship Order"

 

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

This works for my needs. Thanks a bunch. Interesting way you have coded this one. I have not used IN in that fashion. I'll add this to my quiver.

 

Thanks!

AlexAlberga727
Resolver II
Resolver II

@CNENFRNL It seems as if I am following that guidince. <> before ||.

 

Is this how you're interpreting the rules too?

@AlexAlberga727 , yes, <> (comparison operator) is precedent than || (logical operator).


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

CNENFRNL
Community Champion
Community Champion

Hi, @AlexAlberga727 , operators are assigned different precedences; you might want to refer to this table for details and tweak your formula accordingly.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

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.

Top Solution Authors