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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
RodrigoSV
Regular Visitor

Excel Formula to DAX

Hello All,

 

I have an Excel formula that needs to be converted to DAX:

'=IF(AND([@[CREATION DATE < 6 MONTHS]]="";[@[PLANT_LEVEL_STATUS]]="ACTIVE";[@[IS THE LAST INVOICE DATE < 730 DAYS?]]="";[@STOCK]="";[@[DOES IT HAVE OPEN SALES ORDERS?]]="";[@[DOES IT HAVE OPEN PRODUCTION ORDERS?]]="";[@[DOES IT HAVE ACTIVE PURCHASE ORDERS?]]="");"INACT PLANT";
	IF(AND([@[CREATION DATE < 6 MONTHS]]="";[@[PLANT_LEVEL_STATUS]]="ACTIVE";[@[IS THE LAST INVOICE DATE < 730 DAYS?]]="YES");"NO ACTION";
	IF(AND([@[CREATION DATE < 6 MONTHS]]="< 6 months";[@[PLANT_LEVEL_STATUS]]="INACTIVE");"POSSIBLE REACTIVATION PLANT";
	IF(AND([@[CREATION DATE < 6 MONTHS]]="";[@[PLANT_LEVEL_STATUS]]="ACTIVE";[@[IS THE LAST INVOICE DATE < 730 DAYS?]]="";[@STOCK]<>"";[@[DOES IT HAVE OPEN SALES ORDERS?]]="";[@[DOES IT HAVE OPEN PRODUCTION ORDERS?]]="";[@[DOES IT HAVE ACTIVE PURCHASE ORDERS?]]="");"PHASE OUT PLANT";
	))))' AS 'INACT/PHASE OUT',

I have tried to start with a column like this:

Plant Status =
IF(
    AND(
        [CREATION DATE < 6 MONTHS] = BLANK(),
        [PLANT_LEVEL_STATUS] = "ACTIVE",
        [IS THE LAST INVOICE DATE < 730 DAYS?] = BLANK(),
        [STOCK] = BLANK(),
        [DOES IT HAVE OPEN SALES ORDERS?] = BLANK(),
        [DOES IT HAVE OPEN PRODUCTION ORDERS?] = BLANK(),
        [DOES IT HAVE ACTIVE PURCHASE ORDERS?] = BLANK()
    ),
    "INACT PLANT",
    IF(
        AND(
            [CREATION DATE < 6 MONTHS] = BLANK(),
            [PLANT_LEVEL_STATUS] = "ACTIVE",
            [IS THE LAST INVOICE DATE < 730 DAYS?] = "YES"
        ),
        "NO ACTION",

 All the conditions are already created in PBI, however, it seems that my DAX query isn't correct. How should I proceed to replicate it?

Thank you very much!

1 ACCEPTED SOLUTION
BrianConnelly
Resolver III
Resolver III

First, the AND function in DAX accepts only two (2) arguments.  You can't write that in that manner.  Change your code to something like this:

AND(
        [CREATION DATE < 6 MONTHS] = BLANK(),
        AND([PLANT_LEVEL_STATUS] = "ACTIVE",
        AND([IS THE LAST INVOICE DATE < 730 DAYS?] = BLANK(),
        AND([STOCK] = BLANK(),
        AND([DOES IT HAVE OPEN SALES ORDERS?] = BLANK(),
        AND([DOES IT HAVE OPEN PRODUCTION ORDERS?] = BLANK(),[DOES IT HAVE ACTIVE PURCHASE ORDERS?] = BLANK())))))
    )

 

and the second part as:

AND(
            [CREATION DATE < 6 MONTHS] = BLANK(),
            AND([PLANT_LEVEL_STATUS] = "ACTIVE", [IS THE LAST INVOICE DATE < 730 DAYS?] = "YES")
        )

View solution in original post

1 REPLY 1
BrianConnelly
Resolver III
Resolver III

First, the AND function in DAX accepts only two (2) arguments.  You can't write that in that manner.  Change your code to something like this:

AND(
        [CREATION DATE < 6 MONTHS] = BLANK(),
        AND([PLANT_LEVEL_STATUS] = "ACTIVE",
        AND([IS THE LAST INVOICE DATE < 730 DAYS?] = BLANK(),
        AND([STOCK] = BLANK(),
        AND([DOES IT HAVE OPEN SALES ORDERS?] = BLANK(),
        AND([DOES IT HAVE OPEN PRODUCTION ORDERS?] = BLANK(),[DOES IT HAVE ACTIVE PURCHASE ORDERS?] = BLANK())))))
    )

 

and the second part as:

AND(
            [CREATION DATE < 6 MONTHS] = BLANK(),
            AND([PLANT_LEVEL_STATUS] = "ACTIVE", [IS THE LAST INVOICE DATE < 730 DAYS?] = "YES")
        )

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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