简体   繁体   中英

Writing DAX expression with multiple IF conditions (Excel to DAX-Power BI)

I have this formula in Excel and I need it rewritten in DAX but I am unsure how to do this. I am very very new to DAX and so far have only been able to do the basics. I hope someone can help!

Excel Formula:

=IF([@[Date Shipped]]="","",IF([@[Date Exchanged]]="",[@[Date Shipped]]-[@[Date Approved]]+1,[@[Date Shipped]]-[@[Date Exchanged]]+1)-([@[Paused Days (Total)]]*([@[Paused Days (Total)]]<>"")))

My attempt with DAX, disastrous and clearly not correct:

Column = IF(ISBLANK('winnipeg erp_workorder'[Date Shipped]),BLANK(),IF(ISBLANK('winnipeg erp_workorder'[Date Exchanged]),('winnipeg erp_workorder'[Date Shipped]-'winnipeg erp_workorder'[Date Approved])+1),('winnipeg erp_workorder'[Date Shipped]-'winnipeg erp_workorder'[Date Exchanged])+1)-(IF(NOT(ISBLANK('winnipeg erp_workorder'[Paused Days Total],'winnipeg erp_workorder'[Paused Days Total]*'winnipeg erp_workorder'[Paused Days Total]))))

Thank you to anyone who can help!

Carla

It is difficult to provide exact solution without having the PBIX file because in DAX we have Measures and Columns so at the moment I am only guessing that everything that you have inside the code is coming from the columns.

You can use this and modify it to get to the desired result:

Column =
VAR DateShipped = 'winnipeg erp_workorder'[Date Shipped]
VAR DateExchanged = 'winnipeg erp_workorder'[Date Exchanged]
VAR DateApproved = 'winnipeg erp_workorder'[Date Approved]
VAR PausedDaysTotal = 'winnipeg erp_workorder'[Paused Days (Total)]
VAR Result =
    IF (
        NOT ISBLANK ( DateShipped ),
        IF (
            ISBLANK ( DateExchanged ),
            DateShipped - DateApproved + 1,
            DateShipped - DateExchanged + 1 - PausedDaysTotal
        )
    )
RETURN
    Result

Thank you,

Antriksh Sharma

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM