Search code examples
powerbidaxpowerbi-embeddedpowerbi-desktop

DAX Rule with 2 IFs


How would you write the following conditions in DAX (for Power BI) for a measure named RULE:

• If Monthly Net Order Quantity >4 or Monthly Average Final Run Time > 28, returns 1

• If Monthly Average Final Run Time is blank, return blank

• Otherwise return 0

I don't have any DAX knowledge so anyone out there please help! Thank you so much!


Solution

  • For lots of conditions, sometimes it's easier to write a SWITCH:

    RULE =
    SWITCH( TRUE(),
        ISBLANK ( [Monthly Average Final Run Time] ),
        BLANK(),
        [Monthly Net Order Quantity] > 4 || [Monthly Average Final Run Time] > 28,
        1,
        0
    )
    

    This article explains the SWITCH( TRUE(), ... ) construction nicely.