Forum Discussion

erhan_79's avatar
erhan_79
Post Prodigy
5 years ago
Solved

Calculating violation

Hi there ;   i need your kind support for below issue pls :    i have table as below , the yellow marked last colum that i want to create in my table.I need dax formula for column , not measure. ...
  • TomMartens's avatar
    5 years ago

    Hey erhan_79 ,

    I assume this DAX statement allows to create a calculated column that returns what you are looking for:

    violation = 
    var __Material = 'Table'[Material]
    var __Index = 'Table'[Index]
    var __Status =  'Table'[Status]
    var __DeliveryDate = 'Table'[Delivery Date]
    var doSucceedingDeliveriesExist =
        IF( __Status = "Open"
            , IF(
                CALCULATE( 
                    MAX( 'Table'[Delivery Quantity] )
                    , FILTER(
                        ALL( 'Table')
                        , 'Table'[Material] = __Material && 'Table'[Index] > __Index
                    )
                ) > 0
                , "Violation"
                , BLANK()
            )
        )
    var doOpenPreceedingDeliveriesExist =
        IF( __Status = "Closed"
            , IF(
                CALCULATE( 
                    MIN( 'Table'[Delivery Date] )
                    , FILTER(
                        ALL( 'Table')
                        , 'Table'[Material] = __Material && 'Table'[Index] > __Index
                    )
                ) <= __DeliveryDate
                , "Violation"
                , BLANK()
            )
        )
    return
    IF( doSucceedingDeliveriesExist = "Violation" || doOpenPreceedingDeliveriesExist = "Violation"
        , "Violation"
        , BLANK()
    )

    Here is a screenshot of the result, be aware that I call the column violation:

    Hopefully, this provides what you are looking for.

     

    Regards,

    Tom