Forum Discussion

GMadd's avatar
GMadd
Helper I
2 years ago
Solved

Conditional Result based on Dates

I need to create a DAX formula that returns a value based on the dates. I am working with three different dates. Created On Date = When the delivery was created Planned Goods Issue Date = When the ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, GMadd 

     

    Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

     

    Measure:

    Status1 =
    
    VAR _getCreateDate =
    
        SELECTEDVALUE ( 'Table'[Created On] )
    
    VAR _getPlanedDate =
    
        SELECTEDVALUE ( 'Table'[Planned Goods Issue] )
    
    VAR _getShippedDate =
    
        SELECTEDVALUE ( 'Table'[Shipped Date] )
    
    RETURN
    
        SWITCH (
    
            TRUE (),
    
            _getShippedDate - 2 >= _getPlanedDate
    
                && _getShippedDate - 2 >= _getCreateDate, "Late",
    
            _getShippedDate >= _getPlanedDate + 1
    
                || _getShippedDate = _getCreateDate + 1, "Backorder",
    
            _getShippedDate = _getCreateDate, "On-time",
    
            "CheckData"
    
        )

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum